Skip to main content

Module stateutil

Module stateutil 

Source
Expand description

State map utilities for manipulating Petri net state maps.

Functionsยง

apply
Creates a new state by copying base and applying updates.
copy
Creates a deep copy of a state map.
diff
Returns a map of keys where values differ between a and b. Values in the result are from state b.
equal
Returns true if two states have the same keys and values (exact comparison).
equal_tol
Returns true if two states have the same keys and values within tolerance.
filter
Returns a new state containing only keys that pass the predicate.
get
Returns the value for a key, or 0 if not found.
keys
Returns all keys in the state map.
max
Returns the key with the maximum value.
merge
Combines multiple state maps, with later maps taking precedence.
min
Returns the key with the minimum value.
non_zero
Returns keys that have non-zero values.
scale
Returns a new state with all values multiplied by factor.
sum
Returns the sum of all values in the state.
sum_keys
Returns the sum of values for the specified keys.