From 0bc99dd7c2c70abe8ab30bf5e059fa38c205ccec Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sun, 8 Oct 2023 00:17:36 -0400 Subject: [PATCH 1/4] fix --- changelog_entry.yaml | 4 ++++ setup.py | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..ea1fbd062 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: patch + changes: + removed: + - numpy pin. diff --git a/setup.py b/setup.py index 034d394f1..4036fcefa 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,6 @@ "gif[plotly]>=3.0.0", "inquirer>=2.7.0", "microdf_python>=0.3.0", - "numpy<1.22", "pandas", "plotly>=4.14.3", "PolicyEngine-Core>=2.1,<3", From 7635c2b0c6b03366c59c468ba01d951d8fed39be Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sun, 8 Oct 2023 11:06:56 -0400 Subject: [PATCH 2/4] bump core --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4036fcefa..91000a237 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ "microdf_python>=0.3.0", "pandas", "plotly>=4.14.3", - "PolicyEngine-Core>=2.1,<3", + "PolicyEngine-Core>=2.8.1,<3", "pyyaml>=5.3.1", "pytest", "requests>=2.25.1", From 9513d162e9442ceb7ca3d78f4c802ecd74a364c9 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff <35577657+nikhilwoodruff@users.noreply.github.com> Date: Mon, 9 Oct 2023 19:20:40 +0100 Subject: [PATCH 3/4] Fix bug causing test failures --- policyengine_uk/variables/gov/dwp/universal_credit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/policyengine_uk/variables/gov/dwp/universal_credit.py b/policyengine_uk/variables/gov/dwp/universal_credit.py index c344dde8b..51e5974c6 100644 --- a/policyengine_uk/variables/gov/dwp/universal_credit.py +++ b/policyengine_uk/variables/gov/dwp/universal_credit.py @@ -288,7 +288,7 @@ def formula(benunit, period, parameters): tenure_type, [ TenureType.RENT_FROM_COUNCIL, - tenure_type == TenureType.RENT_FROM_HA, + TenureType.RENT_FROM_HA, ], ), tenure_type == TenureType.RENT_PRIVATELY, From 9babdef69e919a105bf9dfe86596e4dae37c45b9 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff <35577657+nikhilwoodruff@users.noreply.github.com> Date: Mon, 9 Oct 2023 19:52:23 +0100 Subject: [PATCH 4/4] Fix test and remove deprecated util --- policyengine_uk/variables/gov/dwp/tax_credits.py | 2 +- .../variables/gov/dwp/universal_credit.py | 9 ++------- .../hmrc/income_tax/charges/child_benefit_hitc.py | 7 ++++--- .../gov/hmrc/national_insurance/class_1.py | 13 +++++++------ .../gov/hmrc/national_insurance/class_4.py | 4 +--- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/policyengine_uk/variables/gov/dwp/tax_credits.py b/policyengine_uk/variables/gov/dwp/tax_credits.py index bae64715e..eae470174 100644 --- a/policyengine_uk/variables/gov/dwp/tax_credits.py +++ b/policyengine_uk/variables/gov/dwp/tax_credits.py @@ -34,7 +34,7 @@ def formula(benunit, period, parameters): "property_income", ] income = add(benunit, period, STEP_1_COMPONENTS) - income = amount_over(income, TC.means_test.non_earned_disregard) + income = max_(income - TC.means_test.non_earned_disregard, 0) STEP_2_COMPONENTS = [ "employment_income", "self_employment_income", diff --git a/policyengine_uk/variables/gov/dwp/universal_credit.py b/policyengine_uk/variables/gov/dwp/universal_credit.py index 51e5974c6..4b9dd363a 100644 --- a/policyengine_uk/variables/gov/dwp/universal_credit.py +++ b/policyengine_uk/variables/gov/dwp/universal_credit.py @@ -284,13 +284,8 @@ def formula(benunit, period, parameters): rent = benunit("benunit_rent", period) max_housing_costs = select( [ - np.isin( - tenure_type, - [ - TenureType.RENT_FROM_COUNCIL, - TenureType.RENT_FROM_HA, - ], - ), + (tenure_type == TenureType.RENT_FROM_COUNCIL) + | (tenure_type == TenureType.RENT_FROM_HA), tenure_type == TenureType.RENT_PRIVATELY, ], [rent, min_(benunit("LHA_cap", period), rent)], diff --git a/policyengine_uk/variables/gov/hmrc/income_tax/charges/child_benefit_hitc.py b/policyengine_uk/variables/gov/hmrc/income_tax/charges/child_benefit_hitc.py index 09082260d..360205f70 100644 --- a/policyengine_uk/variables/gov/hmrc/income_tax/charges/child_benefit_hitc.py +++ b/policyengine_uk/variables/gov/hmrc/income_tax/charges/child_benefit_hitc.py @@ -14,9 +14,10 @@ def formula(person, period, parameters): CB_received = person.benunit("child_benefit", period) CB_HITC = parameters(period).gov.hmrc.income_tax.charges.CB_HITC percentage = ( - amount_over( - person("adjusted_net_income", period), - CB_HITC.phase_out_start, + max_( + person("adjusted_net_income", period) + - CB_HITC.phase_out_start, + 0, ) # HITC is specified as a percent of Child Benefit recollected for # every £1,000 over the phase-out threshold. diff --git a/policyengine_uk/variables/gov/hmrc/national_insurance/class_1.py b/policyengine_uk/variables/gov/hmrc/national_insurance/class_1.py index a1f05afc9..e7b38649b 100644 --- a/policyengine_uk/variables/gov/hmrc/national_insurance/class_1.py +++ b/policyengine_uk/variables/gov/hmrc/national_insurance/class_1.py @@ -35,11 +35,12 @@ def formula(person, period, parameters): * WEEKS_IN_YEAR / MONTHS_IN_YEAR, ) - add_earnings = amount_over( - earnings, - class_1.thresholds.upper_earnings_limit + add_earnings = max_( + earnings + - class_1.thresholds.upper_earnings_limit * WEEKS_IN_YEAR / MONTHS_IN_YEAR, + 0, ) main_charge = class_1.rates.employee.main * main_earnings add_charge = class_1.rates.employee.additional * add_earnings @@ -71,9 +72,9 @@ class employer_NI_class_1(Variable): def formula(person, period, parameters): class_1 = parameters(period).gov.hmrc.national_insurance.class_1 earnings = person("employment_income", period) - main_earnings = amount_over( - earnings, - class_1.thresholds.secondary_threshold * WEEKS_IN_YEAR, + main_earnings = max_( + earnings - class_1.thresholds.secondary_threshold * WEEKS_IN_YEAR, + 0, ) return class_1.rates.employer * main_earnings diff --git a/policyengine_uk/variables/gov/hmrc/national_insurance/class_4.py b/policyengine_uk/variables/gov/hmrc/national_insurance/class_4.py index 91f89daf9..48f0ecef1 100644 --- a/policyengine_uk/variables/gov/hmrc/national_insurance/class_4.py +++ b/policyengine_uk/variables/gov/hmrc/national_insurance/class_4.py @@ -19,9 +19,7 @@ def formula(person, period, parameters): class_4.thresholds.lower_profits_limit, class_4.thresholds.upper_profits_limit, ) - add_amount = amount_over( - profits, class_4.thresholds.upper_profits_limit - ) + add_amount = max_(profits - class_4.thresholds.upper_profits_limit, 0) main_charge = main_amount * class_4.rates.main add_charge = add_amount * class_4.rates.additional return main_charge + add_charge