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. |
Source code in src/flepimop2/backend/abc/__init__.py
28 29 30 31 32 33 34 35 36 37 38 | |
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 |
Source code in src/flepimop2/backend/abc/__init__.py
18 19 20 21 22 23 24 25 26 | |
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
47 48 49 50 51 52 53 54 55 56 57 58 | |
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
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
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
89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
EngineProtocol
¶
Bases: Protocol
Type-definition (Protocol) for engine runner functions.
__call__(stepper, times, state, params, **kwargs)
¶
Protocol for engine runner functions.
Source code in src/flepimop2/engine/abc/__init__.py
30 31 32 33 34 35 36 37 38 39 | |
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. |
Source code in src/flepimop2/parameter/abc/__init__.py
17 18 19 20 21 22 23 24 | |
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
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
SystemABC(*args, **kwargs)
¶
Bases: ModuleABC
Abstract class for Dynamic Systems.
Attributes:
| Name | Type | Description |
|---|---|---|
module |
str
|
The 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
|
Initialize the SystemABC.
The default initialization sets the stepper to a no-op function. Concrete implementations should override this with a valid stepper function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Positional arguments. |
()
|
**kwargs
|
Any
|
Keyword arguments. |
{}
|
Source code in src/flepimop2/system/abc/__init__.py
77 78 79 80 81 82 83 84 85 86 87 88 | |
__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
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
step(time, state, **params)
¶
Perform a single step of the system's dynamics.
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
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
SystemProtocol
¶
Bases: Protocol
Type-definition (Protocol) for system stepper functions.
__call__(time, state, **kwargs)
¶
Protocol for system stepper functions.
Source code in src/flepimop2/system/abc/__init__.py
20 21 22 23 24 | |