From db630cd9445beb48297bd755cb684bcb4ec865e0 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff <35577657+nikhilwoodruff@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:09:08 +0000 Subject: [PATCH] Fix Budget change reforms break on subset simulations #994 (#995) --- CHANGELOG.md | 7 ++++ changelog.yaml | 5 +++ .../contrib/policyengine/budget_change.py | 34 +++++++++++-------- setup.py | 2 +- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5f0d2a72..0d760c1e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.15.1] - 2024-11-05 14:05:53 + +### Fixed + +- Bug in budget change reforms. + ## [2.15.0] - 2024-10-30 17:24:57 ### Added @@ -1591,6 +1597,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +[2.15.1]: https://github.com/PolicyEngine/openfisca-uk/compare/2.15.0...2.15.1 [2.15.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.14.1...2.15.0 [2.14.1]: https://github.com/PolicyEngine/openfisca-uk/compare/2.14.0...2.14.1 [2.14.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.13.2...2.14.0 diff --git a/changelog.yaml b/changelog.yaml index 0ae9dcb91..f25386a74 100644 --- a/changelog.yaml +++ b/changelog.yaml @@ -1335,3 +1335,8 @@ added: - OBR Autumn 2024 EFO economic factors. date: 2024-10-30 17:24:57 +- bump: patch + changes: + fixed: + - Bug in budget change reforms. + date: 2024-11-05 14:05:53 diff --git a/policyengine_uk/variables/contrib/policyengine/budget_change.py b/policyengine_uk/variables/contrib/policyengine/budget_change.py index bd66d28c6..26a7efffe 100644 --- a/policyengine_uk/variables/contrib/policyengine/budget_change.py +++ b/policyengine_uk/variables/contrib/policyengine/budget_change.py @@ -176,6 +176,11 @@ class nhs_budget_change(Variable): value_type = float def formula(household, period, parameters): + budget_increase = ( + parameters(period).gov.contrib.policyengine.budget.nhs * 1e9 + ) + if budget_increase == 0: + return 0 decile = household( "pre_budget_change_ons_household_income_decile", period ) @@ -195,9 +200,6 @@ def formula(household, period, parameters): decile = pd.Series(decile) - budget_increase = ( - parameters(period).gov.contrib.policyengine.budget.nhs * 1e9 - ) budget_increase_per_decile = { i: budget_increase * DECILE_INCIDENCE[i] for i in range(1, 11) } @@ -223,6 +225,12 @@ class education_budget_change(Variable): value_type = float def formula(household, period, parameters): + + budget_increase = ( + parameters(period).gov.contrib.policyengine.budget.education * 1e9 + ) + if budget_increase == 0: + return 0 decile = household( "pre_budget_change_ons_household_income_decile", period ) @@ -241,10 +249,6 @@ def formula(household, period, parameters): } decile = pd.Series(decile) - - budget_increase = ( - parameters(period).gov.contrib.policyengine.budget.education * 1e9 - ) budget_increase_per_decile = { i: budget_increase * DECILE_INCIDENCE[i] for i in range(1, 11) } @@ -270,6 +274,15 @@ class other_public_spending_budget_change(Variable): value_type = float def formula(household, period, parameters): + + budget_increase = ( + parameters( + period + ).gov.contrib.policyengine.budget.other_public_spending + * 1e9 + ) + if budget_increase == 0: + return 0 decile = household( "pre_budget_change_ons_household_income_decile", period ) @@ -288,13 +301,6 @@ def formula(household, period, parameters): } decile = pd.Series(decile) - - budget_increase = ( - parameters( - period - ).gov.contrib.policyengine.budget.other_public_spending - * 1e9 - ) budget_increase_per_decile = { i: budget_increase * DECILE_INCIDENCE[i] for i in range(1, 11) } diff --git a/setup.py b/setup.py index 7ed87436a..f7ce471e1 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name="PolicyEngine-UK", - version="2.15.0", + version="2.15.1", author="PolicyEngine", author_email="nikhil@policyengine.org", classifiers=[