Repository navigation
Canonicalise alias paths in Scenario.apply - #2418
Merged
Merged
Conversation
Scenario.apply on a built simulation edited only the deprecated labor_supply_responses copy, which formulas do not read, unless the scenario had been summed (Scenario.__add__ canonicalises since #2404). It now keys its changes by canonical paths too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
marked this pull request as ready for review
October 15, 2026 09:12
MaxGhenis
added a commit
that referenced
this pull request
Oct 15, 2026
MaxGhenis
added a commit
that referenced
this pull request
Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #2404, from its round-4 review (finding R4-1).
Scenario.apply(simulation), used on an already-built simulation, keyed itsparameter_changesby the literal paths it was given. A deprecatedgov.simulation.labor_supply_responses.*path therefore edited only the alias copy, which no formula reads. Since #2404, a scenario that had been summed (Scenario() + scenario) already carried canonical paths and did change the parameter. So the result depended on whether the scenario had been summed.Scenario(parameter_changes={labor_supply_responses.income_elasticity: 0.3}).apply(sim)labour_supply_responses.income_elasticityScenario() + …)Main's figures come from the round-4 reviewer's reproduction (
r4_apply_alias.py).Fix:
applynow iterates_canonical_paths(self.parameter_changes). That is the same canonicalisation, and the same in-order merge of a path with its alias, thatScenario.__add__andSimulationalready use. Dict values inapplyare nested sub-paths, and merging them in order is unchanged.Reproducer: policyengine_uk/tests/test_process_time_reforms.py::test_scenario_apply_changes_the_parameter_an_alias_path_copies
Local run at a4fa613:
test_process_time_reforms.py+test_dated_reform_routes.py, 148 passed (-n 2).axiom: n/a: infra
🤖 Generated with Claude Code