callback_set
Stable type · Simulation
Tier: stable · Kind: type · Topic: Simulation
| Julia | TypeScript | Python | Rust | Go |
|---|---|---|---|---|
| not exported | outside profile | CallbackSet | CallbackSet | outside profile |
Julia
Julia does not export this type.
TypeScript
Not available in TypeScript. TypeScript is outside the simulation capability profile (Julia, Python, Rust): build an RHS and integrate it; TypeScript and Go are deliberately non-simulating.
Python
class CallbackSet(tuple)
CallbackSet.__add__(other: Any) -> CallbackSet
CallbackSet.__call__(t: Any, y: Any) -> None
An ordered, immutable set of callbacks, declared on a EsmProblem
.
A callback is a callable (t, y) — t the output-time vector and y
the matching state/observed block — invoked once the run has produced its
output nodes, and after every Integrator.step. Callbacks belong to
the document (refreshing a provider buffer, writing an output stream), not
to a particular run’s tolerances, which is why they are declared at
construction.
A callback argument to solve
REPLACES this set entirely — it
does not append, merge, or wrap (§2.5.4). Silent composition is the more
dangerous default: a caller overriding a EsmProblem-level callback would
otherwise get both, and two callbacks that each write output produce a wrong
run rather than an error. To EXTEND rather than replace, read the set back
and compose explicitly:
solve(prob, callback=callbacks(prob) + my_extra_callback)
Members
__add__— Explicit composition — the sanctioned way to EXTEND a EsmProblem’s set.
Rust
pub struct CallbackSet {
/* private fields */
}
impl CallbackSet { pub fn new() -> Self }
impl CallbackSet { pub fn of(name: impl Into<String>, f: CallbackFn) -> Self }
impl CallbackSet { pub fn push(&mut self, name: impl Into<String>, f: CallbackFn) -> &mut Self }
impl CallbackSet { pub fn len(&self) -> usize }
impl CallbackSet { pub fn is_empty(&self) -> bool }
impl CallbackSet { pub fn names(&self) -> Vec<&str> }
impl CallbackSet { pub fn invoke(&self, p: &Progress<'_>) -> Flow }
The callbacks declared on a EsmProblem
.
Callbacks live on the EsmProblem, not on a run: a callback that refreshes provider buffers or writes an output stream belongs to the document, not to a particular run’s tolerances (§2.5.4).
Entries are named so that CallbackSet::names can tell a caller what a
EsmProblem already carries before they decide whether to replace it.
Go
Not available in Go. Go is outside the simulation capability profile (Julia, Python, Rust): build an RHS and integrate it; TypeScript and Go are deliberately non-simulating.