Refactor variables with redundant adds/subtracts and formula definitions #1450
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.
Summary
Fixes #1413 and #1411
Removes redundant formulas from variables where
adds/subtractsattributes were being ignored, which could lead to bugs when the two get out of sync.Changes
Variables refactored (formula removed):
household_net_income: Removed formula that only appliednp.round()- now relies solely onadds/subtractshousehold_net_income_ahc: Removed formula that only appliednp.round()- now relies solely onadds/subtractsVariables verified (no changes needed):
These variables correctly reference
ClassName.addsin their formulas:household_market_income✓household_benefits✓household_tax✓gov_tax✓pre_budget_change_household_benefits✓pre_budget_change_household_tax✓Impact
The two refactored variables previously had formulas that:
np.round()to the resultadds/subtractsattributes misleading documentationBy removing the formulas, these variables now:
adds/subtractsmechanismNote: OpenFisca may handle rounding differently when using
adds/subtractsdirectly vs. applyingnp.round()in a formula, but this appears to be the intended behavior based on the framework design.Test plan
household_net_incomecalculates correctlyhousehold_net_income_ahccalculates correctly🤖 Generated with Claude Code