Calculate the variable variable_name
for the entity and the period period
, using the variable formula if it exists.
Example: >>> person(“salary”, “2017-04”) >>> array([300.0])
Get the rank of a person within an entity according to a criteria. The person with rank 0 has the minimum value of criteria. If condition is specified, then the persons who don’t respect it are not taken into account and their rank is -1.
Example: >>> age = person(“age”, period) # e.g [32, 34, 2, 8, 1] >>> person.get_rank(household, age) >>> [3, 4, 0, 2, 1]
>>> is_child = person.has_role(
... Household.CHILD
... ) # [False, False, True, True, True]
>>> person.get_rank(
... household, -age, condition=is_child
:rtype: :sphinx_autodoc_typehints_type:`\:py\:class\:\`\~numpy.ndarray\`\\ \\\[\:py\:data\:\`\~typing.Any\`\, \:py\:class\:\`\~numpy.dtype\`\\ \\\[\:py\:class\:\`int\`\]\]`
… ) # Sort in reverse order so that the eldest child gets the rank 0. >>> [-1, -1, 1, 0, 2]
Return True
if array
is True
for all members of the entity.
array
must have the dimension of the number of persons in the simulation
If role
is provided, only the entity member with the given role are taken into account.
Example: >>> salaries = household.members( … “salary”, “2018-01” … ) # e.g. [2000, 1500, 0, 0, 0] >>> household.all(salaries >= 1800) >>> array([False])
Return True
if array
is True
for any members of the entity.
array
must have the dimension of the number of persons in the simulation
If role
is provided, only the entity member with the given role are taken into account.
Example: >>> salaries = household.members( … “salary”, “2018-01” … ) # e.g. [2000, 1500, 0, 0, 0] >>> household.any(salaries >= 1800) >>> array([True])
Return the maximum value of array
for the entity members.
array
must have the dimension of the number of persons in the simulation
If role
is provided, only the entity member with the given role are taken into account.
Example: >>> salaries = household.members( … “salary”, “2018-01” … ) # e.g. [2000, 1500, 0, 0, 0] >>> household.max(salaries) >>> array([2000])
Return the minimum value of array
for the entity members.
array
must have the dimension of the number of persons in the simulation
If role
is provided, only the entity member with the given role are taken into account.
Example: >>> salaries = household.members( … “salary”, “2018-01” … ) # e.g. [2000, 1500, 0, 0, 0] >>> household.min(salaries) >>> array([0]) >>> household.min( … salaries, role=Household.PARENT … ) # Assuming the 1st two persons are parents >>> array([1500])
Returns the number of persons contained in the entity.
If role
is provided, only the entity member with the given role are taken into account.
Return the sum of array
for the members of the entity.
array
must have the dimension of the number of persons in the simulation
If role
is provided, only the entity member with the given role are taken into account.
Example: >>> salaries = household.members( … “salary”, “2018-01” … ) # e.g. [2000, 1500, 0, 0, 0] >>> household.sum(salaries) >>> array([3500])