Impulses¶
impulses
¶
Known-time, native-array state updates for explicit integration.
StateImpulse(time, update, name=None)
dataclass
¶
Replace the state at one fixed time with update(time, pre_state).
The pure callback returns the post-state in the same shape, dtype and array
namespace. It must not mutate its input. Parameters may be captured as native
arrays; event times are static, not differentiable inputs. name is an
optional descriptive label, not a semantic identity for the callback.
Examples:
>>> import numpy as np
>>> event = StateImpulse(0.5, lambda time, state: state + 2.0)
>>> event.update(event.time, np.array([1.0, 3.0])).tolist()
[3.0, 5.0]
__post_init__()
¶
Validate static event metadata without evaluating the callback.
Raises:
| Type | Description |
|---|---|
ValueError
|
Time is not a finite real scalar or name is empty. |
TypeError
|
The update is not callable or name is not a string. |
Source code in src/op_engine/impulses.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |