leaspy.io.realizations.CollectionRealization

class CollectionRealization(*, population: DictRealizations | Dict[str, AbstractRealization] | None = None, individual: DictRealizations | Dict[str, AbstractRealization] | None = None)

Bases: DictRealizations

Realizations of population and individual variables, stratified per variable type.

Parameters:
populationDictRealizationsType, optional
individualDictRealizationsType, optional
Attributes:
individual
names

Return the list of variable names.

population
realizations
realizations_dict

Pooled dictionary of realizations, to (almost) provide the common DictRealizations interface.

tensors
tensors_dict

Methods

clone()

Deep-copy of the CollectionRealization instance.

initialize(model, *, n_individuals[, ...])

Initialize the CollectionRealization instance from a Model instance.

initialize_individuals(model, *, n_individuals)

Initialize the individual part of the CollectionRealization instance from a Model instance.

initialize_population(model, *[, skip_variable])

Initialize the population part of the CollectionRealization instance from a Model instance.

clone() CollectionRealization

Deep-copy of the CollectionRealization instance.

In particular the underlying realizations are cloned and detached.

Returns:
CollectionRealization

The cloned collection of realizations.

initialize(model: AbstractModel, *, n_individuals: int, skip_variable: Callable[[dict], bool] | None = None, **realization_init_kws) None

Initialize the CollectionRealization instance from a Model instance.

Parameters:
modelAbstractModel

The model from which to initialize the collection of realizations.

n_individualsint

The number of individuals in the data.

skip_variableCallable or bool, optional

Whether some variables should be skipped or not.

**realization_init_kwsdict

Kwargs for initializing the Realizations.

initialize_individuals(model: AbstractModel, *, n_individuals: int, skip_variable: Callable[[dict], bool] | None = None, **realization_init_kws) None

Initialize the individual part of the CollectionRealization instance from a Model instance.

Parameters:
modelAbstractModel

The model from which to initialize the collection of realizations.

n_individualsint

The number of individuals in the data.

skip_variableCallable or bool, optional

Whether some variables should be skipped or not.

**realization_init_kwsdict

Kwargs for initializing the Realizations.

initialize_population(model: AbstractModel, *, skip_variable: Callable[[dict], bool] | None = None, **realization_init_kws) None

Initialize the population part of the CollectionRealization instance from a Model instance.

Parameters:
modelAbstractModel

The model from which to initialize the collection of realizations.

skip_variableCallable or bool, optional

Whether some variables should be skipped or not.

**realization_init_kwsdict

Kwargs for initializing the Realizations.

property names: List[str]

Return the list of variable names.

property realizations_dict: Dict[str, AbstractRealization]

Pooled dictionary of realizations, to (almost) provide the common DictRealizations interface.