StateVector

phasic.StateVector(state_indexer, indices=None, state=None)

Dict-like interface for multi-PropertySet state with attribute access.

StateVector wraps a StateIndexer and provides convenient access to properties via dictionary syntax or attributes. It maintains both indices and property dict representations for each PropertySet.

Parameters

state_indexer : StateIndexer

StateIndexer defining valid property sets

indices : dict = None

Dict mapping PropertySet names to indices

state : dict = None

Nested dict {pset_name: {prop_name: value}}

Attributes

state_indexer : StateIndexer

Associated state indexer

indices : dict

Current indices for each PropertySet

state : dict

Current property values for each PropertySet

Examples

>>> # Multi-PropertySet usage
>>> indexer = StateIndexer(
...     lineage=[Property('descendants', max_value=10)],
...     metadata=[Property('time_bin', max_value=1000)]
... )
>>> state_vec = StateVector(indexer, state={
...     'lineage': {'descendants': 5},
...     'metadata': {'time_bin': 100}
... })
>>> state_vec.lineage.descendants  # Attribute access
5
>>> state_vec.metadata.time_bin
100
>>> # Backward compatible single PropertySet usage
>>> indexer = StateIndexer([Property('descendants', max_value=10)])
>>> state_vec = StateVector(indexer, indices={'default': 5})
>>> state_vec['default']['descendants']
5

Methods

Name Description
copy Create a copy of this state vector.
update_indices Recompute indices from current state.

copy

phasic.StateVector.copy()

Create a copy of this state vector.

Returns

: StateVector

New StateVector with same indexer and property values.

update_indices

phasic.StateVector.update_indices()

Recompute indices from current state.

Call this after modifying property values via attribute/item assignment.