From 9927c8dea45c4d95cebe3db905edbbf985ff9dc8 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Wed, 15 Oct 2025 12:38:19 +0100 Subject: [PATCH 1/2] Fix random seed --- changelog_entry.yaml | 4 ++++ policyengine_uk/scenarios/uc_reform.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..ae1b54b08 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: patch + changes: + fixed: + - Fixed randomness between runs caused by UC reform. diff --git a/policyengine_uk/scenarios/uc_reform.py b/policyengine_uk/scenarios/uc_reform.py index 363bafc99..1b91c0d1c 100644 --- a/policyengine_uk/scenarios/uc_reform.py +++ b/policyengine_uk/scenarios/uc_reform.py @@ -8,7 +8,9 @@ def add_universal_credit_reform(sim: Microsimulation): sim.tax_benefit_system.parameters.gov.dwp.universal_credit.rebalancing ) - uc_seed = np.random.random(len(sim.calculate("benunit_id"))) + generator = np.random.default_rng(43) + + uc_seed = generator.random(len(sim.calculate("benunit_id"))) p_uc_post_2026_status = { 2025: 0, 2026: 0.11, From f9b8d48c936a6cdea04319b5da4a6b5b20275ea0 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Wed, 15 Oct 2025 12:45:25 +0100 Subject: [PATCH 2/2] Update tests --- .../tests/microsimulation/reforms_config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/policyengine_uk/tests/microsimulation/reforms_config.yaml b/policyengine_uk/tests/microsimulation/reforms_config.yaml index 3cd3f7ff2..2616cc0fc 100644 --- a/policyengine_uk/tests/microsimulation/reforms_config.yaml +++ b/policyengine_uk/tests/microsimulation/reforms_config.yaml @@ -1,10 +1,10 @@ reforms: - name: Raise basic rate by 1pp - expected_impact: 8.0 + expected_impact: 8.1 parameters: gov.hmrc.income_tax.rates.uk[0].rate: 0.21 - name: Raise higher rate by 1pp - expected_impact: 5.0 + expected_impact: 4.9 parameters: gov.hmrc.income_tax.rates.uk[1].rate: 0.42 - name: Raise personal allowance by ~800GBP/year @@ -12,22 +12,22 @@ reforms: parameters: gov.hmrc.income_tax.allowances.personal_allowance.amount: 13000 - name: Raise child benefit by 25GBP/week per additional child - expected_impact: -1.5 + expected_impact: -1.3 parameters: gov.hmrc.child_benefit.amount.additional: 25 - name: Reduce Universal Credit taper rate to 20% - expected_impact: -36.5 + expected_impact: -36.0 parameters: gov.dwp.universal_credit.means_test.reduction_rate: 0.2 - name: Raise Class 1 main employee NICs rate to 10% - expected_impact: 12.4 + expected_impact: 12.5 parameters: gov.hmrc.national_insurance.class_1.rates.employee.main: 0.1 - name: Raise VAT standard rate by 2pp - expected_impact: 21.2 + expected_impact: 19.1 parameters: gov.hmrc.vat.standard_rate: 0.22 - name: Raise additional rate by 3pp - expected_impact: 5.4 + expected_impact: 4.5 parameters: gov.hmrc.income_tax.rates.uk[2].rate: 0.48