people
people
Defines the People class and functions associated with making people and handling the transitions between states (e.g., from susceptible to infected).
Classes
| Name | Description |
|---|---|
| People | A class to perform all the operations on the people – usually not invoked directly. |
People
people.People(pars, strict=True, **kwargs)A class to perform all the operations on the people – usually not invoked directly.
This class is usually created automatically by the sim. The only required input argument is the population size, but typically the full parameters dictionary will get passed instead since it will be needed before the People object is initialized. However, ages, contacts, etc. will need to be created separately – see cv.make_people() instead.
Note that this class handles the mechanics of updating the actual people, while cv.BasePeople takes care of housekeeping (saving, loading, exporting, etc.). Please see the BasePeople class for additional methods.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| pars | dict | the sim parameters, e.g. sim.pars – alternatively, if a number, interpreted as pop_size | required |
| strict | bool | whether or not to only create keys that are already in self.meta.person; otherwise, let any key be set | True |
| kwargs | dict | the actual data, e.g. from a popdict, being specified | {} |
Examples::
ppl1 = cv.People(2000)
sim = cv.Sim()
ppl2 = cv.People(sim.pars)
Methods
| Name | Description |
|---|---|
| check_critical | Check for new progressions to critical |
| check_death | Check whether or not this person died on this timestep |
| check_diagnosed | Check for new diagnoses. Since most data are reported with diagnoses on |
| check_exit_iso | End isolation for anyone due to exit isolation |
| check_inds | Return indices for which the current state is false and which meet the date criterion |
| check_infectious | Check if they become infectious |
| check_quar | Update quarantine state |
| check_recovery | Check for recovery. |
| check_severe | Check for new progressions to severe |
| check_symptomatic | Check for new progressions to symptomatic |
| infect | Infect people and determine their eventual outcomes. |
| init_flows | Initialize flows to be zero |
| initialize | Perform initializations |
| make_naive | Make a set of people naive. This is used during dynamic resampling. |
| make_nonnaive | Make a set of people non-naive. |
| plot | Plot statistics of the population – age distribution, numbers of contacts, |
| schedule_quarantine | Schedule a quarantine. Typically not called by the user directly except |
| set_prognoses | Set the prognoses for each person based on age during initialization. Need |
| story | Print out a short history of events in the life of the specified individual. |
| test | Method to test people. Typically not to be called by the user directly; |
| update_contacts | Refresh dynamic contacts, e.g. community |
| update_states_post | Perform post-timestep updates |
| update_states_pre | Perform all state updates at the current timestep |
check_critical
people.People.check_critical()Check for new progressions to critical
check_death
people.People.check_death()Check whether or not this person died on this timestep
check_diagnosed
people.People.check_diagnosed()Check for new diagnoses. Since most data are reported with diagnoses on the date of the test, this function reports counts not for the number of people who received a positive test result on a day, but rather, the number of people who were tested on that day who are schedule to be diagnosed in the future.
check_exit_iso
people.People.check_exit_iso()End isolation for anyone due to exit isolation
check_inds
people.People.check_inds(current, date, filter_inds=None)Return indices for which the current state is false and which meet the date criterion
check_infectious
people.People.check_infectious()Check if they become infectious
check_quar
people.People.check_quar()Update quarantine state
check_recovery
people.People.check_recovery(inds=None, filter_inds='is_exp')Check for recovery.
More complex than other functions to allow for recovery to be manually imposed for a specified set of indices.
check_severe
people.People.check_severe()Check for new progressions to severe
check_symptomatic
people.People.check_symptomatic()Check for new progressions to symptomatic
infect
people.People.infect(
inds,
hosp_max=None,
icu_max=None,
source=None,
layer=None,
variant=0,
)Infect people and determine their eventual outcomes.
* Every infected person can infect other people, regardless of whether they develop symptoms
* Infected people that develop symptoms are disaggregated into mild vs. severe (=requires hospitalization) vs. critical (=requires ICU)
* Every asymptomatic, mildly symptomatic, and severely symptomatic person recovers
* Critical cases either recover or die
* If the simulation is being run with waning, this method also sets/updates agents' neutralizing antibody levels
Method also deduplicates input arrays in case one agent is infected many times and stores who infected whom in infection_log list.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| inds | array | array of people to infect | required |
| hosp_max | bool | whether or not there is an acute bed available for this person | None |
| icu_max | bool | whether or not there is an ICU bed available for this person | None |
| source | array | source indices of the people who transmitted this infection (None if an importation or seed infection) | None |
| layer | str | contact layer this infection was transmitted on | None |
| variant | int | the variant people are being infected by | 0 |
Returns
| Name | Type | Description |
|---|---|---|
| count | int | number of people infected |
init_flows
people.People.init_flows()Initialize flows to be zero
initialize
people.People.initialize(sim_pars=None)Perform initializations
make_naive
people.People.make_naive(inds, reset_vx=False)Make a set of people naive. This is used during dynamic resampling.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| inds | array | list of people to make naive | required |
| reset_vx | bool | whether to reset vaccine-derived immunity | False |
make_nonnaive
people.People.make_nonnaive(inds, set_recovered=False, date_recovered=0)Make a set of people non-naive.
This can be done either by setting only susceptible and naive states, or else by setting them as if they have been infected and recovered.
plot
people.People.plot(*args, **kwargs)Plot statistics of the population – age distribution, numbers of contacts, and overall weight of contacts (number of contacts multiplied by beta per layer).
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| bins (arr) | age bins to use (default, 0-100 in one-year bins) | required | |
| width (float) | bar width | required | |
| font_size (float) | size of font | required | |
| alpha (float) | transparency of the plots | required | |
| fig_args (dict) | passed to pl.figure() | required | |
| axis_args (dict) | passed to pl.subplots_adjust() | required | |
| plot_args (dict) | passed to pl.plot() | required | |
| do_show (bool) | whether to show the plot | required | |
| fig (fig) | handle of existing figure to plot into | required |
schedule_quarantine
people.People.schedule_quarantine(inds, start_date=None, period=None)Schedule a quarantine. Typically not called by the user directly except via a custom intervention; see the contact_tracing() intervention instead.
This function will create a request to quarantine a person on the start_date for a period of time. Whether they are on an existing quarantine that gets extended, or whether they are no longer eligible for quarantine, will be checked when the start_date is reached.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| inds | int | indices of who to quarantine, specified by check_quar() | required |
| start_date | int | day to begin quarantine (defaults to the current day, sim.t) |
None |
| period | int | quarantine duration (defaults to pars['quar_period']) |
None |
set_prognoses
people.People.set_prognoses()Set the prognoses for each person based on age during initialization. Need to reset the seed because viral loads are drawn stochastically.
story
people.People.story(uid, *args)Print out a short history of events in the life of the specified individual.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| uid | int / list | the person or people whose story is being regaled | required |
| args | list | these people will tell their stories too | () |
Example::
sim = cv.Sim(pop_type='hybrid', verbose=0)
sim.run()
sim.people.story(12)
sim.people.story(795)
test
people.People.test(inds, test_sensitivity=1.0, loss_prob=0.0, test_delay=0)Method to test people. Typically not to be called by the user directly; see the test_num() and test_prob() interventions.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| inds | indices of who to test | required | |
| test_sensitivity | float | probability of a true positive | 1.0 |
| loss_prob | float | probability of loss to follow-up | 0.0 |
| test_delay | int | number of days before test results are ready | 0 |
update_contacts
people.People.update_contacts()Refresh dynamic contacts, e.g. community
update_states_post
people.People.update_states_post()Perform post-timestep updates
update_states_pre
people.People.update_states_pre(t)Perform all state updates at the current timestep