Skip to content

Commit

Permalink
Improve controller stratification naming and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
bgyori committed Jun 13, 2024
1 parent 5f742fe commit 638c85e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 1 addition & 3 deletions mira/metamodel/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,12 @@ def stratify(
# We now apply the stratum assigned to each controller in this particular
# tuple to the controller
for controller, c_stratum in zip(stratified_controllers, c_strata_tuple):
stratified_template.name += f"_{c_stratum}"
controller.with_context(do_rename=modify_names, inplace=True,
**{key: c_stratum})
template_strata.append(c_stratum if param_renaming_uses_strata_names
else stratum_index_map[c_stratum])

tname = stratified_template.name if stratified_template.name \
else 't' + '_'.join(template_strata)
stratified_template.name = tname
# Wew can now rewrite the rate law for this stratified template,
# then append the new template
param_mappings = rewrite_rate_law(template_model=template_model,
Expand Down
4 changes: 4 additions & 0 deletions tests/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def test_stratify_full(self):
)

expected_0 = ControlledConversion(
name="t_unvaccinated_unvaccinated",
subject=susceptible.with_context(vaccination_status="unvaccinated",
do_rename=True),
outcome=infected.with_context(vaccination_status="unvaccinated",
Expand All @@ -54,6 +55,7 @@ def test_stratify_full(self):
)
)
expected_1 = ControlledConversion(
name="t_unvaccinated_vaccinated",
subject=susceptible.with_context(vaccination_status="unvaccinated",
do_rename=True),
outcome=infected.with_context(vaccination_status="unvaccinated",
Expand All @@ -66,6 +68,7 @@ def test_stratify_full(self):
)
)
expected_2 = ControlledConversion(
name="t_vaccinated_unvaccinated",
subject=susceptible.with_context(vaccination_status="vaccinated",
do_rename=True),
outcome=infected.with_context(vaccination_status="vaccinated",
Expand All @@ -78,6 +81,7 @@ def test_stratify_full(self):
)
)
expected_3 = ControlledConversion(
name="t_vaccinated_vaccinated",
subject=susceptible.with_context(vaccination_status="vaccinated",
do_rename=True),
outcome=infected.with_context(vaccination_status="vaccinated",
Expand Down

0 comments on commit 638c85e

Please sign in to comment.