BasePeople#
- class BasePeople[source]#
Bases:
prettyobj
Class for all the people in the simulation.
Attributes
Rounds age up to the next highest integer
Alias to self._inds to prevent accidental overwrite & increase speed
Return ages as an integer
Return ages as integers, clipped to maximum allowable age for pregnancy
Boolean array of everyone female
Boolean array of everyone male
Alias to len(self)
Full length of People array, ignoring filtering
Number of people alive
Methods
- property is_female#
Boolean array of everyone female
- property is_male#
Boolean array of everyone male
- property int_age#
Return ages as an integer
- property ceil_age#
Rounds age up to the next highest integer
- property int_age_clip#
Return ages as integers, clipped to maximum allowable age for pregnancy
- property n#
Number of people alive
- property inds#
Alias to self._inds to prevent accidental overwrite & increase speed
- property len_inds#
Alias to len(self)
- property len_people#
Full length of People array, ignoring filtering
- filter(criteria=None, inds=None)[source]#
Store indices to allow for easy filtering of the People object.
- Parameters:
criteria (bool array) – a boolean array for the filtering critria
inds (array) – alternatively, explicitly filter by these indices
- Returns:
A filtered People object, which works just like a normal People object except only operates on a subset of indices.
- binomial(prob, as_inds=False, as_filter=False)[source]#
Return indices either by a single probability or by an array of probabilities. By default just return the boolean array, but can also return the indices, or the filtered People object.
- Parameters:
prob (float/array) – either a scalar probability, or an array of probabilities of the same length as People
as_inds (bool) – return as list of indices instead of a boolean array
as_filter (bool) – return as filter instead than boolean array