tlo.population module

The Person and Population classes.

class Population(sim, initial_size: int, append_size: int | None = None)[source]

Bases: object

A complete population of individuals.

Useful properties of a population:

sim

The Simulation instance controlling this population.

props

A Pandas DataFrame with the properties of all individuals as columns.

initial_size
props
new_row
new_rows
next_person_id
do_birth()[source]

Create a new person within the population.

TODO: This will over-allocate capacity in the population dataframe for efficiency.

Returns:

id of the new person

make_test_property(name, type_)[source]

Create a new property for test purposes.

When testing a particular method in isolation, it’s helpful to be able to define the properties it reads that would normally be provided by other methods. That is what this is for. It adds an extra column into the property DataFrame for this population, set up with the appropriate type.

This should only be used in tests, not in your actual module code!

Parameters:
  • name – the name of the property to add

  • type – a member of the Types enumeration giving the type of the property