tlo.population module
The Person and Population classes.
- class PatientDetails(population_dataframe: DataFrame, person_id: int)[source]
Bases:
object
Read-only memoized view of population dataframe row.
- class Population(sim, initial_size: int, append_size: int = 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
- row_in_readonly_form(patient_index: int) PatientDetails [source]
Extract a lazily evaluated, read-only view of a row of the population dataframe.
The object returned represents the properties of an individual with properties accessible either using dot based attribute access or squared bracket based indexing using string column names.
- Parameters:
patient_index – Row index of the dataframe row to extract.
- Returns:
Object allowing read-only access to an individuals properties.