metawards.Demographics

class metawards.Demographics(demographics: List[metawards._demographic.Demographic] = <factory>, random_seed: int = None, interaction_matrix: List[List[int]] = None, _names: Dict[str, int] = <factory>, _name: str = None, _version: str = None, _authors: str = None, _contacts: str = None, _references: str = None, _filename: str = None, _repository: str = None, _repository_version: str = None, _repository_branch: str = None)[source]

This class holds metadata about all of the demographics being modelled

__init__(demographics: List[metawards._demographic.Demographic] = <factory>, random_seed: int = None, interaction_matrix: List[List[int]] = None, _names: Dict[str, int] = <factory>, _name: str = None, _version: str = None, _authors: str = None, _contacts: str = None, _references: str = None, _filename: str = None, _repository: str = None, _repository_version: str = None, _repository_branch: str = None) → None

Methods

__init__(demographics, random_seed, …)
add(demographic) Add a demographic to the set to be modelled
copy() Return a copy of this demographics object that should allow a safe reset between runs.
get_index(item) Return the index of the passed item
get_name(item) Return the name of the demographic at ‘item’
load(name, repository, folder, filename) Load the parameters for the specified set of demographics.
specialise(network[, profiler]) Build the set of networks that will model this set of demographics applied to the passed Network.

Attributes

interaction_matrix The interaction matrix between demographics.
random_seed The random seed to used when using any random number generator to resolve decisions needed when allocating individuals to demographics.
add(demographic: metawards._demographic.Demographic)[source]

Add a demographic to the set to be modelled

copy()[source]

Return a copy of this demographics object that should allow a safe reset between runs. This deepcopies things that may change, while shallow copying things that won’t

demographics = None

The list of individual Demographic objects, one for each demographic being modelled

get_index(item)[source]

Return the index of the passed item

get_name(item)[source]

Return the name of the demographic at ‘item’

interaction_matrix = None

The interaction matrix between demographics. This should be a list of lists that shows how demographic ‘i’ affects demographic ‘j’

static load(name: str = None, repository: str = None, folder: str = 'demographics', filename: str = None)[source]

Load the parameters for the specified set of demographics. This will look for a file called f”{name}.json” in the directory f”{repository}/{folder}/{name}.json”

By default this will load nothing.

Alternatively you can provide the full path to the json file via the “filename” argument

Parameters:
  • name (str) – The name of the demographics to load. This is the name that will be searched for in the METAWARDSDATA diseases directory
  • repository (str) – The location of the cloned METAWARDSDATA repository
  • folder (str) – The name of the folder within the METAWARDSDATA repository that contains the diseases
  • filename (str) – The name of the file to load the disease from - this directly loads this file without searching through the METAWARDSDATA repository
Returns:

demographics – The constructed and validated demographics

Return type:

Demographics

random_seed = None

The random seed to used when using any random number generator to resolve decisions needed when allocating individuals to demographics. This is set here so that the Demographics are uniquely determined and reproducible across runs

specialise(network: metawards._network.Network, profiler=None, nthreads: int = 1)[source]

Build the set of networks that will model this set of demographics applied to the passed Network.

Parameters:
  • network (Network) – The overall population model - this contains the base parameters, wards, work and play links that define the model outbreak
  • profiler (Profiler) – Profiler used to profile the specialisation
  • nthreads (int) – Number of threads over which to parallelise the work
Returns:

networks – The set of Networks that represent the model run over the full set of different demographics

Return type:

Networks