Abcs¶
abcs
¶
Abstract base classes for flepimop2 modules.
This module provides abstract base classes (ABCs) for key modules of the flepimop2 pipeline. The ABCs defined here can also be found in their respective submodules, but are re-exported here for developer convenience.
BackendABC
¶
Bases: ModuleABC
Abstract base class for flepimop2 file IO backends.
read(run_meta)
¶
Read a numpy array from storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_meta
|
RunMeta
|
Metadata about the current run. |
required |
Returns:
| Type | Description |
|---|---|
Float64NDArray
|
The numpy array read from storage. |
save(data, run_meta)
¶
Save a numpy array to storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Float64NDArray
|
The numpy array to save. |
required |
run_meta
|
RunMeta
|
Metadata about the current run. |
required |
EngineABC(*args, **kwargs)
¶
Bases: ModuleABC
Abstract class for Engines to evolve Dynamic Systems.
Initialize the EngineABC.
The default initialization sets the runner to a no-op function. Concrete implementations should override this with a valid runner function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments. |
()
|
**kwargs
|
Any
|
Keyword arguments. |
{}
|
Source code in src/flepimop2/engine/abc/__init__.py
run(system, eval_times, initial_state, params, **kwargs)
¶
Run the engine with the provided system and parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemABC
|
The dynamic system to be evolved. |
required |
eval_times
|
Float64NDArray
|
Array of time points for evaluation. |
required |
initial_state
|
Float64NDArray
|
The initial state array. |
required |
params
|
dict[IdentifierString, Any]
|
Additional parameters for the stepper. |
required |
**kwargs
|
Any
|
Additional keyword arguments for the engine. |
{}
|
Returns:
| Type | Description |
|---|---|
Float64NDArray
|
The evolved time x state array. |
Source code in src/flepimop2/engine/abc/__init__.py
validate_system(system)
¶
Validation hook for system properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemABC
|
The system to validate. |
required |
Returns:
| Type | Description |
|---|---|
list[ValidationIssue] | None
|
A list of validation issues, or |
Source code in src/flepimop2/engine/abc/__init__.py
EngineProtocol
¶
Bases: Protocol
Type-definition (Protocol) for engine runner functions.
__call__(stepper, times, state, params, **kwargs)
¶
Protocol for engine runner functions.
ParameterABC
¶
Bases: ModuleABC
Abstract base class for parameters.
sample()
abstractmethod
¶
Sample a value from the parameter.
Returns:
| Type | Description |
|---|---|
Float64NDArray
|
A sampled value from the parameter. |
ProcessABC
¶
Bases: ModuleABC
Abstract base class for flepimop2 processing steps.
execute(*, dry_run=False)
¶
Execute a processing step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dry_run
|
bool
|
If True, the process will not actually execute but will simulate execution. |
False
|
Raises:
| Type | Description |
|---|---|
Flepimop2ValidationError
|
If validation fails during a dry run. |
Source code in src/flepimop2/process/abc/__init__.py
SystemABC
¶
Bases: ModuleABC
Abstract class for Dynamic Systems.
Attributes:
| Name | Type | Description |
|---|---|---|
module |
str
|
The fully-qualified module name for the system. |
state_change |
StateChangeEnum
|
The type of state change. |
options |
dict[str, Any] | None
|
Optional dictionary of additional options the system exposes for
|
__init_subclass__(**kwargs)
¶
Ensure concrete subclasses define a valid state change type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments passed to parent classes. |
{}
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a concrete subclass does not define |
Source code in src/flepimop2/system/abc/__init__.py
bind(params=None, **kwargs)
¶
Create a particular SystemProtocol.
bind() translates a generic model specification into a particular
realization. This can include statically defining parameters, but can
also be called with no arguments to simply get the most flexible
SystemProtocol available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
dict[IdentifierString, Any] | None
|
A dictionary of parameters to statically define for the system. |
None
|
**kwargs
|
Any
|
Additional parameters to statically define for the system. |
{}
|
Returns:
| Type | Description |
|---|---|
SystemProtocol
|
A stepper function for this system with static parameters defined. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If params contains "time" or "state" keys, or parameters not in the System definition, or if the parameter values are incompatible with System definition. |
Source code in src/flepimop2/system/abc/__init__.py
step(time, state, **params)
¶
Perform a single step of the system's dynamics.
Details
This method is only intended to be used for troubleshooting. Calling
this method simply routes to bind() and then invokes the resulting
SystemProtocol with the provided arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
float64
|
The current time. |
required |
state
|
Float64NDArray
|
The current state array. |
required |
**params
|
Any
|
Additional parameters for the stepper. |
{}
|
Returns:
| Type | Description |
|---|---|
Float64NDArray
|
The next state array after one step. |
Source code in src/flepimop2/system/abc/__init__.py
SystemProtocol
¶
Bases: Protocol
Type-definition (Protocol) for system stepper functions.