Skip to content

Configuration

configuration

Representations of parsed configuration files.

AxesGroupModel = dict[IdentifierString, AxisModel] module-attribute

Type alias for the axes block in a configuration file.

AxisModel = Annotated[ContinuousAxisModel | CategoricalAxisModel, Field(discriminator='kind')] module-attribute

Discriminated union of all axis configuration models.

ModuleGroupModel = Annotated[dict[IdentifierString, ModuleModel], BeforeValidator(_to_default_dict)] module-attribute

Module group configuration model for flepimop2.

CategoricalAxisModel

Bases: BaseModel

Configuration model for a categorical axis.

Attributes:

Name Type Description
kind Literal['categorical']

Discriminator field; always "categorical".

labels tuple[str, ...]

Ordered sequence of string category labels.

values tuple[int, ...]

Integer values associated with each label (e.g. for ordinal data or spline interpolation). Must be the same length as labels. Defaults to 1, 2, ..., N where N is len(labels).

Examples:

>>> from flepimop2.configuration._axes import CategoricalAxisModel
>>> CategoricalAxisModel(labels=("foo", "bar", "baz"))
CategoricalAxisModel(kind='categorical', labels=('foo', 'bar', 'baz'), values=(1, 2, 3))

ConfigurationModel

Bases: YamlSerializableBaseModel

Configuration model for flepimop2.

This model serves as the parent container for a parsed configuration file.

Attributes:

Name Type Description
name str | None

An optional name for the configuration.

engines ModuleGroupModel

A dictionary of engine configurations.

systems ModuleGroupModel

A dictionary of system configurations.

backends ModuleGroupModel

A dictionary of backend configurations.

process ModuleGroupModel

A dictionary of process configurations.

parameters ModuleGroupModel

A dictionary of parameter configurations.

simulate dict[IdentifierString, SimulateSpecificationModel]

A dictionary of simulation configurations.

ContinuousAxisModel

Bases: BaseModel

Configuration model for a continuous (float) axis.

Attributes:

Name Type Description
kind Literal['continuous']

Discriminator field; always "continuous".

domain tuple[float, float]

A [lo, hi] pair of floats defining the axis extent.

size int

Number of evenly-spaced points. Required for continuous axes.

spacing Literal['linear', 'log']

Whether points are spaced "linear" or "log"-uniformly.

Examples:

>>> from flepimop2.configuration._axes import ContinuousAxisModel
>>> ContinuousAxisModel(domain=(0.0, 12.0), size=5, spacing="linear")
ContinuousAxisModel(kind='continuous', domain=(0.0, 12.0), size=5, spacing='linear')

ModuleModel

Bases: BaseModel

Module configuration model for flepimop2.

Attributes:

Name Type Description
module str

The module identifier for the configuration. Concrete subclasses may leave this as a general string field or specialize it to a fixed Literal[...] module path.

__pydantic_init_subclass__(**kwargs) classmethod

Finalize the module field for ModuleABC subclasses after model creation.

This keeps the explicit declaration API working while also allowing the shared module="..." class-definition shortcut implemented in ModuleABC.

Parameters:

Name Type Description Default
**kwargs Any

Additional keyword arguments passed to parent classes.

{}
Source code in src/flepimop2/configuration/_module.py
@classmethod
def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:  # noqa: PLW3201
    """
    Finalize the `module` field for `ModuleABC` subclasses after model creation.

    This keeps the explicit declaration API working while also allowing the
    shared `module="..."` class-definition shortcut implemented in `ModuleABC`.

    Args:
        **kwargs: Additional keyword arguments passed to parent classes.

    """
    super().__pydantic_init_subclass__(**kwargs)
    if not issubclass(cls, ModuleABC):
        return
    module = getattr(cls, "module", None)
    field = cls.model_fields.get("module")
    if not isinstance(module, str) or field is None:
        return
    field.annotation = cast("Any", Literal[module])
    field.default = module
    cls.model_rebuild(force=True)

SimulateSpecificationModel

Bases: BaseModel

Model for specifying a simulation for flepimop2.

Attributes:

Name Type Description
engine IdentifierString

The name of the engine to use for the simulation.

system IdentifierString

The name of the system to simulate.

backend IdentifierString

The name of the backend to use for the simulation.

times RangeSpec

A list of time points at which to perform the simulation.

params dict[str, float] | None

Optional dictionary of parameters for the simulation.

scenario IdentifierString | None

Optional name of the scenario to use for the simulation.

t_eval property

Get the evaluation times as a NumPy array.

Returns:

Type Description
Float64NDArray

A NumPy array of evaluation times.