tidy3d.plugins.design.MethodRandomCustom#

class MethodRandomCustom[source]#

Bases: AbstractMethodRandom

Select parameters with an object with a user supplied sampler with a .random method.

Parameters:
  • attrs (dict = {}) – Dictionary storing arbitrary metadata for a Tidy3D object. This dictionary can be freely used by the user for storing data without affecting the operation of Tidy3D as it is not used internally. Note that, unlike regular Tidy3D fields, attrs are mutable. For example, the following is allowed for setting an attr obj.attrs['foo'] = bar. Also note that Tidy3D` will raise a TypeError if attrs contain objects that can not be serialized. One can check if attrs are serializable by calling obj.json().

  • name (Optional[str] = None) – Optional name for the sweep method.

  • num_points (PositiveInt) – Maximum number of sampling points to perform in the sweep.

  • sampler (Optional[Any] = None) – An object with a .random(n) method, which returns a np.ndarray of shape (n, d) where d is the number of dimensions of the design space. Values must lie between [0, 1] and will be re-scaled depending on the design parameters. Compatible objects include instances of scipy.stats.qmc.QMCEngine, but other objects can also be supplied.

Example

>>> import tidy3d.plugins.design as tdd
>>> import scipy.stats.qmc as qmc
>>> sampler = qmc.Halton(d=3)
>>> method = tdd.MethodRandomCustom(num_points=20, sampler=sampler)

Attributes

Methods

get_sampler(parameters)

Sampler for this Method class.

Inherited Common Usage

sampler#
get_sampler(parameters)[source]#

Sampler for this Method class. If None, sets a default.

__hash__()#

Hash method.