Repository navigation
Support parameter entries in income tax allowance aggregates - #2986
juaristi22 wants to merge 3 commits into
Conversation
Partially addresses #2924. Resolve scalar parameter operands using Core's aggregate contract while preserving the existing rounding bound.
Aggregate impact on certified data: passBase Checks: 0 broken by this change, 1 failing on both sides, 0 fixed. Moves flagged for review: 0 (thresholds in Notes
Moves flagged for reviewNone. Spending by benefit and service
Caseloads
Household net income by decileNo household's net income changes in any year. No change in any year: receipts by tax head; government balance, each component counted once; model totals; household income totals; population; poverty rates; people in poverty; inequality; mean household net income in each side's own deciles; standard reform costings (change in gov_balance); standard reforms: change in each reform's target. Checks failing on both base and head (1)
Counted-once checkThe check raised each of 101 components by £1 per unit in 2026-27 and read every head of its totals household by household: its own head must rise by exactly £1, no other tax head may move, no other benefit may rise, and the model's own total must move by what its heads moved. A response that is not finite breaks every rule. The check measures a head that breaks a rule twice more: once holding every other head at its baseline value, and once holding every other head at its value after the first £1 while the component rises again. The head fails where either measurement still shows the response. The check cannot hold a head at a value that is not finite. In each unit where another head is not finite after the first £1, it holds that head at its baseline value, and the second measurement judges no household the unit belongs to. There a head fails wherever it first broke a rule, or wherever the check could not confirm whether its response contains the component. 0 failed and the check skipped 0.
Provenance
Dataset: Receipts by tax head: head levels
Spending by benefit and service: head levels
Caseloads: head levels
Government balance, each component counted once: head levels
Model totals: head levels
Household income totals: head levels
Population: head levels
Poverty rates: head levels
People in poverty: head levels
Inequality: head levels
Mean household net income in each side's own deciles: head levels
Standard reform costings (change in gov_balance): head levels
Standard reforms: change in each reform's target: head levels
|
vahid-ahmadi
left a comment
There was a problem hiding this comment.
Quick pass. This looks right.
- Variable first. Resolving operands as core does (a variable name first, then a parameter path read at the period's start) fixes the
VariableNotFoundErrorwhen an allowance'saddsnames a scalar parameter. - Shared resolver.
_listednow usesget_parameter(root, path)(period.start)instead of walking the attributes by hand, which matches what core does. - Error bound. Giving a scalar parameter a nil bound of its own, while the stored sum that contains it keeps its float32 rounding distance, is correct.
One small point: for a parameter, np.zeros_like(values(name)) makes a 0-d array. It broadcasts fine where it's summed with person arrays, but a test where the parameter is the only component would confirm the shape. The 15 end-to-end regressions may already cover this.
Review drafted with AI assistance and checked against the code at 499676cda528974e09e96112fbfe99e542f06fd5.
|
Following the sole-scalar component test request: Should-address fixedAdded two cases in which a synthetic scalar parameter supplies the only allowance component, covering literal and parameter-held component lists. Both assert the full two-person allowance and tax shapes, the scalar's zero error bound with shape VerificationAfter integrating the actual base, the combined aggregate/allocation run passed all 90 tests: 17 aggregate and 73 allocation tests, including both new cases. Formatting, lint and diff checks passed. Independent verification found no new issues. The helper and its lookup/error-bound behavior did not change. The broader suite was not rerun for this fix. |
Partially addresses #2924.
Core accepts scalar parameter paths in allowance
addsandsubtracts, including component lists stored in parameters. The Marriage Allowance calculation instead tried to read those parameters as variables and raisedVariableNotFoundError.Use Core’s variable-first operand resolution and retain float64 parameter values when reconstructing an aggregate. The aggregate’s existing rounding residual remains in its error bound. The issue’s separate numerical boundary cases remain open.
Validation: 135 Python checks passed, including 15 new end-to-end regressions and the existing allocation and CPS switch tests; 101 policy cases passed across seven related fixture files.
make formatand lint passed. Full repository and private-data suites were not run locally; the documentation site did not change.Reproducer: policyengine_uk/tests/test_income_tax_parameter_aggregates.py::test_scalar_parameter_allowances_reach_tax_outputs
axiom: n/a: Core aggregate operand compatibility; no policy provision or parameter changed.