Logo
  • Features
  • Installation instructions
  • Model data
  • Quick Start Guide
  • Tutorial
  • Input files and formats
  • Usage
  • Running on a cluster
  • Help and support
  • Contributing
  • Developer Support
  • Roadmap
  • Packaging releases
  • Developer’s guide
  • Snag list
  • Documentation
    • MetaWards.app
    • MetaWards
      • MetaWards API Detail
        • Classes
        • Functions
    • MetaWards.iterators
    • MetaWards.extractors
    • MetaWards.mixers
    • MetaWards.movers
    • MetaWards.analysis
    • MetaWards.utils
    • MetaWards.themes
  • Changelog
  • Acknowledgements
MetaWards
  • »
  • Documentation »
  • MetaWards »
  • MetaWards API Detail »
  • metawards.Links
Next Previous

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.

__init__(N: int = 0)[source]¶

Create a container for up to “N” Links

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.
__getitem__(i: int)[source]¶

Return the link at index ‘i’. Note that this is a deep copy of the link. Changing the link will not change the data in this container. To update the data in this container you need to use __setitem__, e.g. via the index operator (see __setitem__)

__init__(N: int = 0)[source]

Create a container for up to “N” Links

__len__()[source]¶

Return the number of links in this container

__setitem__(i: int, value: metawards._link.Link)[source]¶

Set the item as index ‘i’ equal to ‘value’. This deep-copies ‘value’ into this container

assert_not_null()[source]¶

Assert that this collection of links is not null

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)

population() → int[source]¶

Return the population of these links

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
Next Previous

Last updated on Jul 22, 2020.