Typing¶
typing
¶
Custom Typing Helpers.
This module centralizes type aliases used throughout the project and makes it easy to keep runtime imports lightweight while still providing precise type information. The goal is to express common shapes and dtypes once, so internal modules can share consistent, readable annotations without repeating NumPy typing boilerplate.
Examples:
>>> from flepimop2.typing import Float64NDArray
>>> Float64NDArray
numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]
Float64NDArray = npt.NDArray[np.float64]
module-attribute
¶
Alias for a NumPy ndarray with float64 data type.
IdentifierString = Annotated[str, Field(min_length=1, max_length=255, pattern='^[a-z]([a-z0-9\\_]*[a-z0-9])?$'), AfterValidator(_identifier_string)]
module-attribute
¶
A string type representing a valid identifier for named configuration elements.
RaiseOnMissing = RaiseOnMissingType()
module-attribute
¶
Sentinel value indicating an error should be raised if a value is missing.
EngineProtocol
¶
Bases: Protocol
Type-definition (Protocol) for engine runner functions.
__call__(stepper, times, state, params, **kwargs)
¶
Protocol for engine runner functions.
RaiseOnMissingType
¶
A sentinel type indicating an error should be raised if a value is missing.
StateChangeEnum
¶
Bases: StrEnum
Enumeration of types of state changes in a system.
Examples:
>>> from flepimop2.typing import StateChangeEnum
>>> StateChangeEnum.DELTA
<StateChangeEnum.DELTA: 'delta'>
>>> StateChangeEnum.FLOW
<StateChangeEnum.FLOW: 'flow'>
DELTA = 'delta'
class-attribute
instance-attribute
¶
The state change is described directly by the changes in the state variables, i.e. \( x(t + \Delta t) = x(t) + \Delta x \).
ERROR = 'error'
class-attribute
instance-attribute
¶
The state change is mis-specified.
FLOW = 'flow'
class-attribute
instance-attribute
¶
The state change is described directly by the flow rates, or derivatives, of the state variables. I.e. \( dx/dt = f(x, t) \).
STATE = 'state'
class-attribute
instance-attribute
¶
The state change is described directly by the new state values, i.e. \( x(t + \Delta t) = x_{new} \).
SystemProtocol
¶
Bases: Protocol
Type-definition (Protocol) for system stepper functions.
as_system_protocol(func)
¶
Decorator to mark a function as a SystemProtocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
_SystemCallable[_P]
|
A callable matching the SystemProtocol signature. |
required |
Returns:
| Type | Description |
|---|---|
SystemProtocol
|
The function cast as SystemProtocol. |