observed_definition
Stable function · Variable classification
Tier: stable · Kind: function · Topic: Variable classification
| Julia | TypeScript | Python | Rust | Go |
|---|---|---|---|---|
observed_definition | not exported | not exported | not exported | ObservedDefinition |
Julia
observed_definition(model::Model, name::AbstractString)
observed_definition(model::Model, name::AbstractString) -> Union{ASTExpr,Nothing}
The defining right-hand side of the observed unknown name, or nothing when
it is not an observed unknown of model. Convenience over
observed_definitions
for a single lookup.
TypeScript
TypeScript does not export this function.
Python
Python does not export this function.
Rust
Rust does not export this function.
Go
func ObservedDefinition(model *Model, name string) (Expression, bool)
ObservedDefinition returns the defining RHS of an observed unknown — the RHS of the first equation whose LHS names it, bare (y ~ f(…)) or indexed (y[i] ~ f(…)) — and whether one exists. An observed’s definition lives in the model’s equations (esm-spec §6.3.1), so passes that need it (units propagation, array-shape checking, the cadence leaf seed) read it here.
Example (inspect)
doc, err := esm.LoadPath(fixture("decay.esm"))
if err != nil {
log.Fatal(err)
}
for _, name := range sortedKeys(doc.Models) {
model := doc.Models[name]
fmt.Println(name, sortedKeys(model.Variables))
fmt.Println("ODE states:", esm.ODEStates(&model))
fmt.Println("observed:", esm.ObservedUnknowns(&model))
fmt.Println("algebraic:", esm.AlgebraicUnknowns(&model))
fmt.Println("constant parameters:", esm.ConstantParameters(&model))
fmt.Println(esm.IsODEState(&model, "N"), esm.IsODEState(&model, "half_life"))
if def, ok := esm.ObservedDefinition(&model, "half_life"); ok {
fmt.Println("half_life =", esm.ToASCII(def))
}
}