From f60c6bde2eec5941fb359e0a685bcd4eb81e58e0 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Thu, 5 Nov 2026 09:23:04 -0500 Subject: [PATCH 1/2] Supply yearly input in subsampling holder test Co-Authored-By: Claude Opus 5.5 --- changelog.d/spm-subsample-test-core552.fixed.md | 1 + policyengine_us/tests/core/test_spm_system.py | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 changelog.d/spm-subsample-test-core552.fixed.md diff --git a/changelog.d/spm-subsample-test-core552.fixed.md b/changelog.d/spm-subsample-test-core552.fixed.md new file mode 100644 index 00000000000..fc0610014bc --- /dev/null +++ b/changelog.d/spm-subsample-test-core552.fixed.md @@ -0,0 +1 @@ +Updated the subsampling holder test to supply a yearly input before checking reform storage. diff --git a/policyengine_us/tests/core/test_spm_system.py b/policyengine_us/tests/core/test_spm_system.py index ee343a4c1b4..4d3536e8f74 100644 --- a/policyengine_us/tests/core/test_spm_system.py +++ b/policyengine_us/tests/core/test_spm_system.py @@ -900,6 +900,10 @@ def test_subsampling_never_changes_which_policy_a_holder_belongs_to( # Core 3.33.1 and later discard calculated caches when rebuilding; # earlier versions imported them as inputs. Calculate again so # both behaviors exercise holders for the reform's definitions. + # Supply an input to exercise yearly storage after the rebuild. + changed.set_input( + "is_household_head", 2024, np.ones(changed.person.count, dtype=bool) + ) for variable in ("reform_only_income", "is_household_head"): changed.calculate(variable, 2024) holder = changed.get_holder(variable) From 862156d8710b2870fa3c8c06c855e1e2a361deae Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 7 Nov 2026 13:30:47 -0500 Subject: [PATCH 2/2] Carry over a 2022 input in the dataset rebuild provenance test The test stored its 2023 derived entry with put_in_cache, which leaves no fast-cache return, so the adapter's pre-rebuild snapshot never saw that key under core#552. Supply 2022 at construction instead: the 2023 read carries it over and caches a derived return on both cores, and the test now asserts that return reaches _derived_cached_returns. Co-Authored-By: Claude Opus 5.5 --- .../tests/core/test_social_security_real_core.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/policyengine_us/tests/core/test_social_security_real_core.py b/policyengine_us/tests/core/test_social_security_real_core.py index 29e5ff44f62..f5025a82d54 100644 --- a/policyengine_us/tests/core/test_social_security_real_core.py +++ b/policyengine_us/tests/core/test_social_security_real_core.py @@ -437,17 +437,22 @@ def load(self): def test_dataset_rebuild_keeps_new_input_provenance_when_old_cache_shares_key(): from policyengine_core.data import Dataset - simulation = SimulationBuilder().build_from_variables(make_system(), {}) + # The 2022 input carries over to 2023. Both cores cache that carry-over + # as a derived return under the key the dataset's input then reuses, so + # the adapter's pre-rebuild snapshot captures it. + simulation = SimulationBuilder().build_from_variables( + make_system(), {"independent_input": {"2022": [0.0]}} + ) assert scalar(simulation, PUBLIC, "2023") == 0 since = earliest_source_dependency(simulation, requested="2023") assert since is not None assert scalar(simulation, "independent_input", "2023") == 0 old_holder = simulation.get_holder("independent_input") - # Core may leave a missing input's default uncached. Store the derived - # entry this test needs under the key the dataset's input then reuses. - old_holder.put_in_cache(np.array([0.0]), period("2023"), derived=True) assert old_holder.is_derived(period("2023")) assert sequence_number(simulation, "independent_input", "2023") >= since + assert ("independent_input", period("2023")) in hooks._derived_cached_returns( + simulation + ) class TinyDataset: data_format = Dataset.TIME_PERIOD_ARRAYS