metawards.Links¶
-
class
metawards.
Links
(N: int = 0)[source]¶ This is a container class for Links. This uses arrays to store a list of Link objects as a “struct of arrays”. This should improve speed of loading and access.
Methods
__init__
(N)Create a container for up to “N” Links assert_not_null
()Assert that this collection of links is not null assert_valid_index
(i)Assert that the passed index ‘i’ is valid for this collection. copy
()Return a copy of these links, using a shallow copy for things that stay the same (e.g. is_null
()population
()Return the population of these links resize
(N)Resize this container to hold ‘N’ links. scale_susceptibles
(ratio)Scale the number of susceptibles in these Links by the passed scale ratio. -
assert_valid_index
(i)[source]¶ Assert that the passed index ‘i’ is valid for this collection. This will return the index with Python reverse indexing, so that “-1” refers to the last link in the collection
-
copy
()[source]¶ Return a copy of these links, using a shallow copy for things that stay the same (e.g. ifrom, ito, distance) and a deep copy for things that are variable (e.g. weight and suscept)
-
resize
(N: int)[source]¶ Resize this container to hold ‘N’ links. This will expand the container if ‘N’ is greater than len(self), or will contract the container (deleting excess links) if ‘N’ is less than len(self). This function is called typically when you pre-allocate a large Links container, and then want to reduce the size to fit the number of loaded links
-
scale_susceptibles
(ratio: any = None)[source]¶ Scale the number of susceptibles in these Links by the passed scale ratio. This can be a value, e.g. ratio = 2.0 will scale the total number of susceptibles by 2.0. This can also be lists of values, where ward[i] will be scaled by ratio[i]. They can also be dictionaries, e.g. ward[i] scaled by ratio[i]
Parameters: ratio (None, float, list or dict) – The amount by which to scale the total population of susceptibles - evenly scales the work and play populations Returns: Return type: None
-