SimulationConfig#

class dynode.config.simulation_config.SimulationConfig(*, initializer: Initializer, compartments: List[Compartment], parameters: Params)#

Bases: BaseModel

An ODE compartment model configuration file.

__init__(**data: Any) None#

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Methods

flatten_bins()

Flatten all compartments down to list of bins.

flatten_dims()

Flatten all compartments down to list of dimensions.

get_compartment(compartment_name)

Search for and return a Compartment if it exists.

Attributes

idx

An enum-like structure for compartments and their dimensions.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

initializer

compartments

parameters

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

initializer: Initializer#
compartments: List[Compartment]#
parameters: Params#
property idx#

An enum-like structure for compartments and their dimensions.

Note#

This is a cache property, so it will only be computed once, modifications to the compartments will not change the enum after it is created.

Returns#

SimpleNamespace: A namespace containing compartments and their dimensions.

_validate_no_shared_compartment_names() Self#

Validate that no two compartments have the same name.

_validate_shared_compartment_dimensions() Self#

Validate that any dimensions with same name across compartments are equal.

_validate_immune_histories() Self#

Validate that the immune history dimensions within each compartment are initialized from the same strain definitions.

Example#

If you have 2 strains, x and y, - a FullStratifiedImmuneHistory should have 4 bins, none, x, y, x_y - a LastStrainImmuneHistory should have 3 bins, none, x, y - Neither class should bins with any other strain z or exclude one of the required bins.

_create_introduction_ages_mask_encoding() Self#

Parse Strain’s introduction_ages to a binary mask.

_validate_introduced_strains() Self#

Validate that all introduced strains have the same age binning as defined by the Model’s compartments.

get_compartment(compartment_name: str) Compartment#

Search for and return a Compartment if it exists.

Parameters#

compartment_namestr

name of the compartment to return

Returns#

Compartment

Compartment class with matching name.

Raises#

AssertionError

raise if compartment_name not found within self.compartments

flatten_bins() list[Bin]#

Flatten all compartments down to list of bins.

Returns#

list[Bin]

flattened compartments’ bin objects.

Note#

This operation preserves the order of the compartments, dimensions, and bins in the final flattened output.

flatten_dims() list[Dimension]#

Flatten all compartments down to list of dimensions.

Returns#

list[Dimension]

flattened compartments’ Dimension objects.

Note#

This operation preserves the order of the compartments, and dimensions, in the final flattened output.

_abc_impl = <_abc._abc_data object>#