Bases: ABC
Represents properties common to sets of people.
A set is typically going to be used as a set of people within a particular Venue who behave in a certain way.
They will usually have something in common that means they are distinguished from other people in that Venue,
e.g. in how they behave, or in how susceptible they are to the disease.
Source code in may/population/abstract_set.py
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 | class AbstractSet(ABC):
"""Represents properties common to sets of people.
A set is typically going to be used as a set of people within a particular Venue who behave in a certain way.
They will usually have something in common that means they are distinguished from other people in that Venue,
e.g. in how they behave, or in how susceptible they are to the disease.
"""
@abstractmethod
def _collate(self, attribute: str, ifnot=False) -> list["Person"]:
"""Collates Persons from the set that have a particular attribute == True.
Requires that the attribute called for is truthy (a boolean).
Args:
attribute (str): the attribute to look at (e.g. 'dead', or 'susceptible', or 'infected').
ifnot (bool, optional): if True, looks for people where the attribute is False.
Returns:
(list[Person]) : a list of people filtered so the given attribute is True/False.
"""
pass
@property
def size_collated(self, attribute, ifnot=False) -> int:
""" """
return len(self._collate(attribute, ifnot=ifnot))
@property
def size(self) -> int:
""" """
return len(self.members)
@property
def contains_people(self) -> bool:
"""Whether or not the group contains people.
"""
return self.size > 0
|
contains_people
property
Whether or not the group contains people.