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, pop_trend=None, pop_age_trend=None, **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 hpv.make_people() instead.

Note that this class handles the mechanics of updating the actual people, while hpv.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 n_agents required
strict bool whether or not to only create keys that are already in self.meta.person; otherwise, let any key be set True
pop_trend dataframe a dataframe of years and population sizes, if available None
kwargs dict the actual data, e.g. from a popdict, being specified {}

Examples::

ppl1 = hpv.People(2000)

sim = hpv.Sim()
ppl2 = hpv.People(sim.pars)

Methods

Name Description
add_births Add more people to the population
apply_death_rates Apply death rates to remove people from the population
check_cancer Check for new progressions to cancer
check_cancer_deaths Check for new deaths from cancer
check_cin Check for new progressions to CIN
check_clearance Check for HPV clearance.
check_inds Return indices for which the current state is false and which meet the date criterion
check_inds_true Return indices for which the current state is true and which meet the date criterion
check_migration Check if people need to immigrate/emigrate in order to make the population
check_progress Wrapper function for all the new progression checks
create_partnerships Create partnerships. All the hard work of creating the contacts is done by hppop.make_contacts,
dissolve_partnerships Dissolve partnerships
increment_age Let people age by one timestep
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.
plot Plot statistics of the population – age distribution, numbers of contacts,
remove_people Remove people - used for death and migration
scale_flows Return the scaled versions of the flows – replacement for len(inds)
set_prognoses Assigns prognoses for all infected women on day of infection.
set_severity Set severity levels for individual women
story Print out a short history of events in the life of the specified individual.
update_states_post State updates at the end of the current timestep
update_states_pre Perform all state updates at the current timestep
add_births
people.People.add_births(
    year=None,
    new_births=None,
    ages=0,
    immunity=None,
    sex_ratio=0.5,
    hiv_prevalence=None,
)

Add more people to the population

Specify either the year from which to retrieve the birth rate, or the absolute number of new people to add. Must specify one or the other. People are added in-place to the current People instance.

apply_death_rates
people.People.apply_death_rates(year=None)

Apply death rates to remove people from the population NB people are not actually removed to avoid issues with indices

check_cancer
people.People.check_cancer(genotype)

Check for new progressions to cancer

check_cancer_deaths
people.People.check_cancer_deaths()

Check for new deaths from cancer

check_cin
people.People.check_cin(genotype)

Check for new progressions to CIN

check_clearance
people.People.check_clearance(genotype)

Check for HPV clearance.

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_inds_true
people.People.check_inds_true(current, date, filter_inds=None)

Return indices for which the current state is true and which meet the date criterion

check_migration
people.People.check_migration(year=None)

Check if people need to immigrate/emigrate in order to make the population size correct.

check_progress
people.People.check_progress(what, genotype)

Wrapper function for all the new progression checks

create_partnerships
people.People.create_partnerships(
    tind,
    mixing,
    layer_probs,
    f_cross_layer,
    m_cross_layer,
    dur_pship,
    acts,
    age_act_pars,
)

Create partnerships. All the hard work of creating the contacts is done by hppop.make_contacts, which in turn relies on hpu.create_edgelist for creating the edgelist. This method is just a light wrapper that passes in the arguments in the right format and the updates relationship info stored in the People class.

dissolve_partnerships
people.People.dissolve_partnerships(t=None)

Dissolve partnerships

increment_age
people.People.increment_age()

Let people age by one timestep

infect
people.People.infect(inds, g=None, layer=None)

Infect people and determine their eventual outcomes. 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
g int int of genotype to infect people with None
layer str contact layer this infection was transmitted on None
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)

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
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
remove_people
people.People.remove_people(inds, cause=None)

Remove people - used for death and migration

scale_flows
people.People.scale_flows(inds)

Return the scaled versions of the flows – replacement for len(inds) followed by scale factor multiplication

set_prognoses
people.People.set_prognoses(inds, g, gpars, dt)

Assigns prognoses for all infected women on day of infection.

set_severity
people.People.set_severity(inds, g, gpars, dt, set_sev=True)

Set severity levels for individual women Args: inds: indices of women to set severity for g: genotype index dt: timestep set_sev: whether or not to set initial severity

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 = hpv.Sim(pop_type='hybrid', verbose=0)
sim.run()
sim.people.story(12)
sim.people.story(795)
update_states_post
people.People.update_states_post(t, year=None)

State updates at the end of the current timestep

update_states_pre
people.People.update_states_pre(t, year=None)

Perform all state updates at the current timestep