Repository navigation
Pass is_tax through to detailed_budget - #972
Merged
Merged
Conversation
build_detailed_budget dropped policyengine.py's is_tax flag, so consumers signed each program from their own lists. Once policyengine.py adds a row for every UK budget component a reform changes, a benefit missing from those lists (Scottish Child Payment, PIP) would be drawn as a tax. DetailedBudgetProgramOutput gains an optional is_tax (null in outputs built before it), copied from each program-statistics row. Fixes #971 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 27, 2026
PavelMakarchuk
marked this pull request as ready for review
October 27, 2026 22:04
anth-volk
approved these changes
Oct 28, 2026
anth-volk
left a comment
Contributor
There was a problem hiding this comment.
Looks good. Passing is_tax through detailed_budget lets the v3 chart sign each row from the result itself, and results stored before this still validate because the field is optional.
One minor, optional wording point: the DetailedBudgetProgramOutput description says is_tax is None only in outputs built before the flag was recorded, but _is_tax also returns None for any row without a boolean flag (as the build_detailed_budget docstring says).
As you noted, this and policyengine-app-v2#1451 need to merge and deploy before a .py release with PolicyEngine/policyengine.py#724 reaches sim-api.
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.
Fixes #971
Change
DetailedBudgetProgramOutputgainsis_tax: bool | None = None. It is optional, so stored outputs without it still validate, and it is null when a row has no flag.build_detailed_budgetcopiesis_taxfrom each program-statistics row (a numpy scalar is unwrapped; anything that isn't a bool becomes null).is_taxproperty onDetailedBudgetProgramOutput.Why now
PolicyEngine/policyengine.py#724 adds a UK row for every tax and benefit in the budget totals that a reform changes. The v3 app chart decides which rows are benefits from its own
BENEFIT_PROGRAMSset, so new benefit rows such asscottish_child_paymentandpipwould be drawn as taxes. On report 4738 (2027 UC freeze), Scottish Child Payment would show −£25m instead of +£25m. With this flag the app signs rows byis_tax(PolicyEngine/policyengine-app-v2#1451). This should deploy before a .py release with #724 reaches sim-api.Testing
test_simulation_output_budget.py: each program carries its flag (Universal Credit and Scottish Child Payment as benefits, income tax as a tax), and the flag stays null when rows have none.is_tax.projects/policyengine-apis-integcould not be checked locally because it needs the generated clients, which CI builds.🤖 Generated with Claude Code