Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ per-file-ignores."src/ttsim/typing.py" = [
"PYI051", # Redundant literal union
]
per-file-ignores."src_mettsim/mettsim/middle_earth/**/*.py" = [
"PLR1714", # Consider merging multiple comparisons with `in` — not vectorizable
"PLR1716", # Boolean expression may be simplified with chained comparison — not vectorizable
"PLR2004", # Magic value comparison
"RET505", # Vectorizer requires both if/else branches; it rejects the early-return form
]
Expand Down
12 changes: 11 additions & 1 deletion src_mettsim/mettsim/middle_earth/demographics.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
from __future__ import annotations

from ttsim.tt import AggType, agg_by_group_function
from ttsim.tt import AggType, agg_by_group_function, policy_function


@agg_by_group_function(agg_type=AggType.COUNT)
def number_of_individuals_kin(
kin_id: int, # noqa: ARG001
) -> int:
return 1


@policy_function(vectorization_strategy="vectorize")
def coming_of_age_celebration(age: int) -> bool:
"""Whether the person reaches a coming-of-age milestone this year.

Hobbits come of age at 33 and famously celebrate their eleventy-first
(111th) birthday.
"""
return age == 33 or age == 111
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,12 @@ def adult(
max_age_children: int,
) -> bool:
return age > max_age_children


@policy_function(vectorization_strategy="vectorize")
def young_adult(
age: int,
max_age_children: int,
) -> bool:
"""Whether the person is a young adult: past child age but not yet of age."""
return max_age_children < age and age < 33
Loading