Compile¶
compile
¶
op_system.compile.
Compile normalized RHS specifications into efficient, runnable callables.
This module is domain-agnostic and intentionally does not import flepimop2.
Contract¶
- Accepts
NormalizedRhs(fromop_system.specs) and produces aCompiledRhsobject containing aneval_fnsuitable for numerical backends. - Raises built-in exceptions with standardized messages.
Security note¶
This module uses eval() on code objects compiled from user-provided strings.
To reduce risk, expressions are parsed and validated with a conservative AST
whitelist, and evaluation runs with empty builtins.
CompiledRhs(state_names, param_names, eval_fn)
dataclass
¶
Container for a compiled RHS evaluation function.
bind(params)
¶
Bind parameter values and return a 2-arg RHS: rhs(t, y) -> dydt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
Mapping[str, object]
|
Mapping of parameter names to values. |
required |
Returns:
| Type | Description |
|---|---|
Callable[[float64, Float64Array], Float64Array]
|
A callable |
Source code in src/op_system/compile.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
EvalFn
¶
Bases: Protocol
Callable RHS evaluator supporting runtime parameter kwargs.
compile_rhs(rhs)
¶
Compile a normalized RHS into a runnable evaluation function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rhs
|
NormalizedRhs
|
Normalized RHS produced by |
required |
Returns:
| Type | Description |
|---|---|
CompiledRhs
|
A |
Source code in src/op_system/compile.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | |