From 1dba0719f51c58720d11e7c374f55d705b06894b Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Tue, 10 Nov 2026 17:02:34 -0500 Subject: [PATCH 1/2] Sample ordinary parameters from outside every calendar-year series test_ordinary_parameters_read_every_key_as_before drew its ordinary parameters from every gov leaf outside yoy_growth, so it also drew the energy price indices, which read calendar years. A pull request that moves the derandomized sample onto one of them fails the check. The ordinary list and the calendar-year check now share one prefix tuple, and a new test asserts that no ordinary parameter reads calendar years. Co-Authored-By: Claude Opus 5.5 --- .../tests/test_process_time_reforms.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/policyengine_uk/tests/test_process_time_reforms.py b/policyengine_uk/tests/test_process_time_reforms.py index d67fa29932..0255b27b9c 100644 --- a/policyengine_uk/tests/test_process_time_reforms.py +++ b/policyengine_uk/tests/test_process_time_reforms.py @@ -57,6 +57,8 @@ LAGGED_CPI = f"{GROWTH}.obr.lagged_cpi" INDICES = "gov.economic_assumptions.indices" ENERGY_PRICES = "gov.economic_assumptions.energy_prices" +# The calendar-year series on the gov tree (invariant 2). +CALENDAR_YEAR_SERIES = (f"{GROWTH}.", f"{INDICES}.", f"{ENERGY_PRICES}.") CPI_INDEX = f"{INDICES}.obr.consumer_price_index" INPUTS = "gov.economic_assumptions.statutory_uprating_inputs" AWE = f"{INPUTS}.awe_total_pay_may_july" @@ -324,9 +326,7 @@ def test_calendar_year_series_are_the_growth_rates_indices_and_household_tree(): for path in paths: if path.startswith("baseline."): continue - expected = path.startswith( - (f"{GROWTH}.", f"{INDICES}.", f"{ENERGY_PRICES}.", "household.") - ) + expected = path.startswith(CALENDAR_YEAR_SERIES + ("household.",)) assert reads(path) is expected, path assert not reads("gov.not.a.parameter") @@ -600,8 +600,7 @@ def statutory_leaves(): ORDINARY = [ path for path in statutory_leaves() - if path.startswith("gov.") - and not path.startswith(("gov.economic_assumptions.yoy_growth.",)) + if path.startswith("gov.") and not path.startswith(CALENDAR_YEAR_SERIES) ] KEYS = st.one_of( st.integers(2016, 2040), @@ -613,6 +612,12 @@ def statutory_leaves(): ) +def test_no_ordinary_parameter_reads_calendar_years(): + reads = tbs_module.parameter_reads_calendar_years() + assert ORDINARY + assert [path for path in ORDINARY if reads(path)] == [] + + @settings(max_examples=200, deadline=None, derandomize=True) @given(path=st.sampled_from(ORDINARY), key=KEYS) def test_ordinary_parameters_read_every_key_as_before(path, key): From 6b3d7db90bdda37d153ece4c57d0b8a5fca69e32 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Tue, 10 Nov 2026 17:47:02 -0500 Subject: [PATCH 2/2] Add a changelog fragment for the ordinary-parameter sampling fix Co-Authored-By: Claude Opus 5.5 --- changelog.d/fix-ordinary-calendar-year-sampling.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/fix-ordinary-calendar-year-sampling.fixed.md diff --git a/changelog.d/fix-ordinary-calendar-year-sampling.fixed.md b/changelog.d/fix-ordinary-calendar-year-sampling.fixed.md new file mode 100644 index 0000000000..e45d745454 --- /dev/null +++ b/changelog.d/fix-ordinary-calendar-year-sampling.fixed.md @@ -0,0 +1 @@ +Fixed test_ordinary_parameters_read_every_key_as_before, which drew some of its ordinary parameters from the household energy price indices, a calendar-year series.