leaspy.samplers.sampler_factory

sampler_factory(sampler: str | AbstractSampler, variable_type: VariableType, **kwargs) AbstractSampler

Factory for Samplers.

Parameters:
samplerAbstractSampler or str

If an instance of a subclass of AbstractSampler, returns the instance (no copy). If a string, returns a new instance of the appropriate class (with optional parameters kwargs).

variable_typeVariableType

The type of random variable that the sampler is supposed to sample.

**kwargs

Optional parameters for initializing the requested Sampler (not used if input is a subclass of AbstractSampler).

Returns:
AbstractSampler

The desired sampler.

Raises:
LeaspyAlgoInputError:

If the sampler provided is not supported.