synthpops.workplaces module

class Workplace(wpid=None, **kwargs)[source]

Bases: synthpops.base.LayerGroup

A class for individual workplaces and methods to operate on each.

Parameters:kwargs (dict) – data dictionary of the workplace

Class constructor for empty workplace.

Parameters:
  • **wpid (int) – workplace id
  • **member_uids (np.array) – ids of workplace members
validate()[source]

Check that information supplied to make a workplace is valid and update to the correct type if necessary.

get_workplace(pop, wpid)[source]

Return workplace with id: wpid.

Parameters:
  • pop (sp.Pop) – population
  • wpid (int) – workplace id number
Returns:

A populated workplace.

Return type:

sp.Workplace

add_workplace(pop, workplace)[source]

Add a workplace to the list of workplaces.

Parameters:
  • pop (sp.Pop) – population
  • workplace (sp.Workplace) – workplace with at minimum the wpid and member_uids.
initialize_empty_workplaces(pop, n_workplaces=None)[source]

Array of empty workplaces.

Parameters:
  • pop (sp.Pop) – population
  • n_workplaces (int) – the number of workplaces to initialize
populate_workplaces(pop, workplaces)[source]

Populate all of the workplaces. Store each workplace at the index corresponding to it’s wpid.

Parameters:
  • pop (sp.Pop) – population
  • workplaces (list) – list of lists where each sublist represents a workplace and contains the ids of the workplace members

Notes

If number of workplaces (n) is fewer than existing workplaces, it will only replace the first n workplaces. Otherwise the existing workplaces will be overwritten by the input workplaces.

count_employment_by_age(popdict)[source]

Get employment count by age for workers in the popdict. Workers can be in different possible layers: as staff in long term care facilities (LTCF), as teachers or staff in schools (S), or as workers in other workplaces (W).

Parameters:popdict (dict) – population dictionary
Returns:Dictionary of the count of employed people by age in popdict.
Return type:dict
get_employment_rates_by_age(employment_count_by_age, age_count)[source]

Get employment rates by age.

Parameters:
  • employment_count_by_age (dict) – dictionary of the count of employed people
  • age_count (dict) – dictionary of the age count
Returns:

Dictionary of the employment rates by age.

Return type:

dict

get_workplace_sizes(popdict)[source]

Get workplace sizes of regular workplaces in popdict. This only includes workplaces that are not long term care facilities (LTCF) or schools (S).

Parameters:popdict (dict) – population dictionary
Returns:Dictionary of the generated workplace sizes for each regular workplace.
Return type:dict
get_generated_workplace_size_distribution(workplace_sizes, bins)[source]

Get workplace size distribution.

Parameters:
  • workplace_sizes (dict) – generated workplace sizes by workplace id (wpid)
  • bins (list) – workplace size bins
Returns:

Dictionary of generated workplace size distribution.

Return type:

dict