BasePeople#

class BasePeople[source]#

Bases: prettyobj

Class for all the people in the simulation.

Attributes

ceil_age

Rounds age up to the next highest integer

inds

Alias to self._inds to prevent accidental overwrite & increase speed

int_age

Return ages as an integer

int_age_clip

Return ages as integers, clipped to maximum allowable age for pregnancy

is_female

Boolean array of everyone female

is_male

Boolean array of everyone male

len_inds

Alias to len(self)

len_people

Full length of People array, ignoring filtering

n

Number of people alive

Methods

__add__(people2)[source]#

Combine two people arrays

keys()[source]#

Returns keys for all properties of the people object

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

plot(fig_args=None, hist_args=None)[source]#

Plot histograms of each quantity

filter(criteria=None, inds=None)[source]#

Store indices to allow for easy filtering of the People object.

Parameters:
  • criteria (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.

unfilter()[source]#

An easy way of unfiltering the People object, returning the original.

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