Skip to content

Commit 68e4558

Browse files
register event_year as a stratification (#547)
1 parent e7a6ad7 commit 68e4558

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
**4.3.12 - 10/06/25**
2+
3+
- Register event_year as a stratification in the ResultsStratifier
4+
15
**4.3.11 - 09/24/25**
26

37
- Refactor: Simplify LBWSG parsing logic

src/vivarium_public_health/results/stratification.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,14 @@ def register_stratifications(self, builder: Builder) -> None:
6262
is_vectorized=True,
6363
requires_columns=["current_time"],
6464
)
65-
# TODO [MIC-4232]: simulants occasionally have event year of end_year_year+1 if the end time plus step size
66-
# lands in the next year. possible solution detailed in ticket
67-
# builder.results.register_stratification(
68-
# "event_year",
69-
# [str(year) for year in range(self.start_year, self.end_year + 1)],
70-
# mapper=self.map_year,
71-
# is_vectorized=True,
72-
# requires_columns=["event_time"],
73-
# )
65+
builder.results.register_stratification(
66+
"event_year",
67+
[str(year) for year in range(self.start_year, self.end_year + 2)],
68+
excluded_categories=[str(self.end_year + 1)],
69+
mapper=self.map_year,
70+
is_vectorized=True,
71+
requires_columns=["event_time"],
72+
)
7473
# TODO [MIC-3892]: simulants occasionally have entrance year of start_year-1 if the start time minus step size
7574
# lands in the previous year. possible solution detailed in ticket
7675
# builder.results.register_stratification(

tests/results/test_stratification.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,14 @@ def test_results_stratifier_register_stratifications(mocker):
104104
is_vectorized=True,
105105
requires_columns=["current_time"],
106106
)
107-
# builder.results.register_stratification.assert_any_call(
108-
# "event_year",
109-
# years_list,
110-
# mapper=rs.map_year,
111-
# is_vectorized=True,
112-
# requires_columns=["event_time"],
113-
# )
107+
builder.results.register_stratification.assert_any_call(
108+
"event_year",
109+
years_list + [str(int(years_list[-1]) + 1)],
110+
excluded_categories=[str(int(years_list[-1]) + 1)],
111+
mapper=rs.map_year,
112+
is_vectorized=True,
113+
requires_columns=["event_time"],
114+
)
114115
# builder.results.register_stratification.assert_any_call(
115116
# "entrance_year",
116117
# years_list,
@@ -129,7 +130,7 @@ def test_results_stratifier_register_stratifications(mocker):
129130
builder.results.register_stratification.assert_any_call(
130131
"sex", ["Female", "Male"], requires_columns=["sex"]
131132
)
132-
assert builder.results.register_stratification.call_count == 3
133+
assert builder.results.register_stratification.call_count == 4
133134

134135

135136
def test_results_stratifier_map_age_groups():

0 commit comments

Comments
 (0)