leaspy.models.noise_models.factory module

Defines the noise model factory.

export_noise_model(noise_model: BaseNoiseModel) Dict[str, Any]

Serialize a given BaseNoiseModel as a dict.

Parameters:
noise_modelBaseNoiseModel

The noise model to serialize.

Returns:
KwargsType

The noise model serialized as a dict.

noise_model_factory(noise_model: str | BaseNoiseModel | Dict[str, Any], **kws) BaseNoiseModel

Factory for noise models.

Parameters:
noise_modelstr or BaseNoiseModel or dict [ str, …]
  • If an instance of a subclass of BaseNoiseModel, returns the instance.

  • If a string, then returns a new instance of the appropriate class (with optional parameters kws).

  • If a dictionary, it must contain the ‘name’ key and other initialization parameters.

**kws

Optional parameters for initializing the requested noise-model when a string.

Returns:
BaseNoiseModel

The desired noise model.

Raises:
LeaspyModelInputError

If noise_model is not supported.