TwoDimensionalArr#
- class TwoDimensionalArr(name=None, dtype=None, default=None, nan=None, label=None, skip_init=False, people=None, ncols=1)[source]#
Bases:
Arr
A State that tracks a two-dimensional array of values, indexed by UIDs. Because this is a true State, it is linked to People and can grow dynamically as new agents are added. It is used for storing state that has multiple columns, such as the ages at which a child is born.
It can be indexed by UIDs, slices, or boolean arrays, and supports setting values for new agents.
example usage: self[uid]: returns the entire row of values for the specified uid self[uid, col]: returns the value in the specified column for the specified uid self[slice]: returns all rows for the specified slice self[bool_arr]: returns all rows where the boolean array is True
- Parameters:
name (str) – Name of the array
dtype (type) – Data type of the array (e.g., np.float64)
default – Default value to use when setting new agents
nan – Value to use for NaN entries
label (str) – Label for the array, used in plots and reports
skip_init (bool) – If True, do not initialize the array; useful for module state definitions
Attributes
auids
Link to the indices of active agents -- sim.people.auids
isnan
notnan
Return BoolArr for non-NaN values
notnanvals
Return values that are not-NaN
Return the values of the active agents
Methods
- property values#
Return the values of the active agents