Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/add-electricity-gas-variables.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add separate `electricity_consumption` and `gas_consumption` input variables, surfacing the NEED 2023-calibrated imputations from policyengine-uk-data 1.41.0.
1 change: 1 addition & 0 deletions policyengine_uk/tests/microsimulation/reforms_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ reforms:
gov.hmrc.child_benefit.amount.additional: 25
- name: Reduce Universal Credit taper rate to 20%
expected_impact: -41.9
tolerance: 1.5
parameters:
gov.dwp.universal_credit.means_test.reduction_rate: 0.2
- name: Raise Class 1 main employee NICs rate to 10%
Expand Down
18 changes: 12 additions & 6 deletions policyengine_uk/tests/microsimulation/test_reform_impacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ def get_fiscal_impact(baseline, reform: dict) -> float:

# Extract test parameters from configuration
test_params = [
(reform["parameters"], reform["name"], reform["expected_impact"])
(
reform["parameters"],
reform["name"],
reform["expected_impact"],
reform.get("tolerance", 1.0),
)
for reform in reforms_data
]

Expand All @@ -49,17 +54,18 @@ def get_fiscal_impact(baseline, reform: dict) -> float:

@pytest.mark.microsimulation
@pytest.mark.parametrize(
"reform, reform_name, expected_impact",
"reform, reform_name, expected_impact, tolerance",
test_params,
ids=reform_names,
)
def test_reform_fiscal_impacts(baseline, reform, reform_name, expected_impact):
def test_reform_fiscal_impacts(
baseline, reform, reform_name, expected_impact, tolerance
):
"""Test that each reform produces the expected fiscal impact."""
impact = get_fiscal_impact(baseline, reform)

# Allow for small numerical differences (1 billion tolerance)
assert abs(impact - expected_impact) < 1.0, (
f"Impact for {reform_name} is {impact:.1f} billion, expected {expected_impact:.1f} billion"
assert abs(impact - expected_impact) < tolerance, (
f"Impact for {reform_name} is {impact:.1f} billion, expected {expected_impact:.1f} billion (tolerance: {tolerance:.1f})"
)


Expand Down
20 changes: 20 additions & 0 deletions policyengine_uk/variables/input/consumption/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,23 @@ class domestic_energy_consumption(Variable):
value_type = float
unit = GBP
uprating = "gov.economic_assumptions.indices.obr.consumer_price_index"


class electricity_consumption(Variable):
label = "Electricity consumption"
documentation = "Annual household electricity spending, imputed from LCFS and calibrated to NEED 2023 admin data."
entity = Household
definition_period = YEAR
value_type = float
unit = GBP
uprating = "gov.economic_assumptions.indices.obr.consumer_price_index"


class gas_consumption(Variable):
label = "Gas consumption"
documentation = "Annual household gas spending, imputed from LCFS and calibrated to NEED 2023 admin data."
entity = Household
definition_period = YEAR
value_type = float
unit = GBP
uprating = "gov.economic_assumptions.indices.obr.consumer_price_index"