metawards.movers.MoveGenerator

class metawards.movers.MoveGenerator(from_demographic: Optional[Union[str, int, List[Union[str, int]]]] = None, to_demographic: Optional[Union[str, int, List[Union[str, int]]]] = None, from_stage: Optional[Union[str, int, List[Union[str, int]]]] = None, to_stage: Optional[Union[str, int, List[Union[str, int]]]] = None, from_ward: Optional[Union[str, int, metawards._wardid.WardID, List[Union[str, int, metawards._wardid.WardID]]]] = None, to_ward: Optional[Union[str, int, metawards._wardid.WardID, List[Union[str, int, metawards._wardid.WardID]]]] = None, fraction: float = 1.0, number: Optional[int] = None)[source]
__init__(from_demographic: Optional[Union[str, int, List[Union[str, int]]]] = None, to_demographic: Optional[Union[str, int, List[Union[str, int]]]] = None, from_stage: Optional[Union[str, int, List[Union[str, int]]]] = None, to_stage: Optional[Union[str, int, List[Union[str, int]]]] = None, from_ward: Optional[Union[str, int, metawards._wardid.WardID, List[Union[str, int, metawards._wardid.WardID]]]] = None, to_ward: Optional[Union[str, int, metawards._wardid.WardID, List[Union[str, int, metawards._wardid.WardID]]]] = None, fraction: float = 1.0, number: Optional[int] = None)[source]
Initialise the generator to generate moves between the

specified demographics, and/or stages, and/or wards.

Parameters
  • from_demographic (int, str or list of int / str) – The ID(s) of the demographic(s) to move from. This can be either a single demographic (identified by an integer ID or string), a list of demographics, or, if None, then all demographics.

  • to_demographic (int, str or list of int / str) – The ID(s) of the demographic to move to. This can be either a single demographic (identified by an integer ID or string), a list of demographics, or, if None, then all demographics. If this is not set, then it is equal to “from_demo”

  • from_stage (int, str or list of int / str) – The ID(s) of the disease stage(s) to move from. This can be either a single stage (identified by an integer ID or string), a list of stages, or, if None, then all stages.

  • to_stage (int, str or list of int / str) – The ID(s) of the disease stage(s) to move to. This can be either a single stage (identified by an integer ID or string), a list of stages, or, if None, then all stages. If this is not set, then it is equal to “from_stage”

  • from_ward (int, str, WardID, or list of int / str / WardID) – The ID(s) of the ward(s) or ward-links(s) to move from. This can be either a single ward or ward-link (identified by an integer ID or string or WardID), a list of ward(s)/ward link(s), or, if None, then all wards and ward links.

  • to_ward (int, str, WardID, or list of int / str / WardID) – The ID(s) of the ward(s) or ward-links(s) to move to. This can be either a single ward or ward-link (identified by an integer ID or string or WardID), a list of ward(s)/ward link(s), or, if None, then all wards and ward links. If this is not set then it is equal to “from_ward”

  • fraction (float) – The fraction of individuals in each ward to move, e.g. 0.75 would move 75% of the individuals in a ward / ward-link. By default 100% are moved.

  • number (int) – The maximum number of individuals in each ward / ward-link to move. The fraction is taken from min(number, number_in_ward). By default all individuals in a ward / ward-link are sampled.

Methods

__delattr__(name, /)

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__(value, /)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__([from_demographic, to_demographic, ...])

Initialise the generator to generate moves between the

__init_subclass__

This method is called when a class is subclassed.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__ne__(value, /)

Return self!=value.

__new__(**kwargs)

__reduce__()

Helper for pickle.

__reduce_ex__(protocol, /)

Helper for pickle.

__repr__()

Return repr(self).

__setattr__(name, value, /)

Implement setattr(self, name, value).

__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__

Abstract classes can override this to customize issubclass().

fraction()

Return the fraction of individuals in each ward or ward-link who should be moved

generate(network)

Return a list indexes of the demographics plus infexes of the disease stages for from and to for the passed networok.

generate_wards(network)

Return a list of ward to ward moves for workers and players.

number()

Return the maximum number of individuals in each ward of ward-link who should move

should_move_all()

Return whether or not all individuals in the specified demographics / disease stages should be moved

Attributes

__dict__

__doc__

__module__

__weakref__

list of weak references to the object (if defined)

__init__(from_demographic: Optional[Union[str, int, List[Union[str, int]]]] = None, to_demographic: Optional[Union[str, int, List[Union[str, int]]]] = None, from_stage: Optional[Union[str, int, List[Union[str, int]]]] = None, to_stage: Optional[Union[str, int, List[Union[str, int]]]] = None, from_ward: Optional[Union[str, int, metawards._wardid.WardID, List[Union[str, int, metawards._wardid.WardID]]]] = None, to_ward: Optional[Union[str, int, metawards._wardid.WardID, List[Union[str, int, metawards._wardid.WardID]]]] = None, fraction: float = 1.0, number: Optional[int] = None)[source]
Initialise the generator to generate moves between the

specified demographics, and/or stages, and/or wards.

Parameters
  • from_demographic (int, str or list of int / str) – The ID(s) of the demographic(s) to move from. This can be either a single demographic (identified by an integer ID or string), a list of demographics, or, if None, then all demographics.

  • to_demographic (int, str or list of int / str) – The ID(s) of the demographic to move to. This can be either a single demographic (identified by an integer ID or string), a list of demographics, or, if None, then all demographics. If this is not set, then it is equal to “from_demo”

  • from_stage (int, str or list of int / str) – The ID(s) of the disease stage(s) to move from. This can be either a single stage (identified by an integer ID or string), a list of stages, or, if None, then all stages.

  • to_stage (int, str or list of int / str) – The ID(s) of the disease stage(s) to move to. This can be either a single stage (identified by an integer ID or string), a list of stages, or, if None, then all stages. If this is not set, then it is equal to “from_stage”

  • from_ward (int, str, WardID, or list of int / str / WardID) – The ID(s) of the ward(s) or ward-links(s) to move from. This can be either a single ward or ward-link (identified by an integer ID or string or WardID), a list of ward(s)/ward link(s), or, if None, then all wards and ward links.

  • to_ward (int, str, WardID, or list of int / str / WardID) – The ID(s) of the ward(s) or ward-links(s) to move to. This can be either a single ward or ward-link (identified by an integer ID or string or WardID), a list of ward(s)/ward link(s), or, if None, then all wards and ward links. If this is not set then it is equal to “from_ward”

  • fraction (float) – The fraction of individuals in each ward to move, e.g. 0.75 would move 75% of the individuals in a ward / ward-link. By default 100% are moved.

  • number (int) – The maximum number of individuals in each ward / ward-link to move. The fraction is taken from min(number, number_in_ward). By default all individuals in a ward / ward-link are sampled.

fraction()[source]

Return the fraction of individuals in each ward or ward-link who should be moved

generate(network: Union[metawards._network.Network, metawards._networks.Networks])[source]

Return a list indexes of the demographics plus infexes of the disease stages for from and to for the passed networok. This returns a list of quads of indicies, e.g.

[[from_demographic, from_stage, to_demographic, to_stage],

[from_demographic, from_stage, to_demographic, to_stage], …

]

generate_wards(network)[source]

Return a list of ward to ward moves for workers and players. This returns None if all individuals should be moved

number()[source]

Return the maximum number of individuals in each ward of ward-link who should move

should_move_all()[source]

Return whether or not all individuals in the specified demographics / disease stages should be moved