Model.update_state()#
- Model.update_state(position, model_state=None, inplace=False, *, allow_weak_vars=False)[source]#
Updates and returns a model state given a position.
- Parameters:
position (
dict[str,Any]) – A dictionary of variable or node names and values.model_state (
dict[str,NodeState] |None, default:None) – A dictionary of node names and their correspondingNodeState. IfNone(default), the model’s current state is used.inplace (
bool, default:False) – IfFalse(default), a new model state is returned, while the current model’s state is left unchanged. IfTrue, the current model’s state is updated in place.allow_weak_vars (
bool, default:False) – IfFalse(default), weak variables remain read-only. IfTrue, entries inpositionkeyed by weak variable names are written directly to the cached value of the variable’s value node and downstream nodes are updated accordingly. Positions must be unambiguous: no weak variable entry may be combined with another entry targeting the same value node, an ancestor, or a descendant. Transient weak variables cannot be set this way.
- Return type:
Warning
The
model_statemust be up-to-date, i.e. it must not contain any outdated nodes. Updates can only be triggered through new variable or node values in theposition. If you supply amodel_statewith outdated nodes, these nodes and their outputs will not be updated.