88FRS households at 2023 price levels.
99"""
1010
11- import numpy as np
1211import pytest
1312from policyengine_uk import Microsimulation
1413from policyengine_uk .data import UKSingleYearDataset
@@ -77,7 +76,8 @@ def test_electricity_by_income(arrays):
7776 for lo , hi , band , _ , elec_kwh in NEED_INCOME_BANDS :
7877 target = elec_kwh * OFGEM_Q4_2023_ELEC_RATE
7978 mask = (income >= lo ) & (income < hi )
80- if mask .sum () == 0 : continue
79+ if mask .sum () == 0 :
80+ continue
8181 imp = _wmean (elec [mask ], w [mask ])
8282 tol = HIGH_INC_TOL if lo >= 100_000 else BAND_TOL
8383 rows .append ((band , imp , target , abs (imp - target ) / target , tol ))
@@ -92,7 +92,8 @@ def test_gas_by_income(arrays):
9292 for lo , hi , band , gas_kwh , _ in NEED_INCOME_BANDS :
9393 target = gas_kwh * OFGEM_Q4_2023_GAS_RATE
9494 mask = (income >= lo ) & (income < hi )
95- if mask .sum () == 0 : continue
95+ if mask .sum () == 0 :
96+ continue
9697 imp = _wmean (gas [mask ], w [mask ])
9798 tol = HIGH_INC_TOL if lo >= 100_000 else BAND_TOL
9899 rows .append ((band , imp , target , abs (imp - target ) / target , tol ))
@@ -107,7 +108,8 @@ def test_electricity_by_tenure(arrays):
107108 for frs_val , need_key in TENURE_TO_NEED .items ():
108109 target = NEED_TENURE_ELEC [need_key ] * OFGEM_Q4_2023_ELEC_RATE
109110 mask = tenure == frs_val
110- if mask .sum () == 0 : continue
111+ if mask .sum () == 0 :
112+ continue
111113 imp = _wmean (elec [mask ], w [mask ])
112114 rows .append ((frs_val , imp , target , abs (imp - target ) / target ))
113115 _check ("Electricity £/yr by tenure" , rows )
@@ -119,7 +121,8 @@ def test_gas_by_tenure(arrays):
119121 for frs_val , need_key in TENURE_TO_NEED .items ():
120122 target = NEED_TENURE_GAS [need_key ] * OFGEM_Q4_2023_GAS_RATE
121123 mask = tenure == frs_val
122- if mask .sum () == 0 : continue
124+ if mask .sum () == 0 :
125+ continue
123126 imp = _wmean (gas [mask ], w [mask ])
124127 rows .append ((frs_val , imp , target , abs (imp - target ) / target ))
125128 _check ("Gas £/yr by tenure" , rows )
@@ -131,7 +134,8 @@ def test_electricity_by_accommodation(arrays):
131134 for frs_val , need_key in ACCOMM_TO_NEED .items ():
132135 target = NEED_ACCOMM_ELEC [need_key ] * OFGEM_Q4_2023_ELEC_RATE
133136 mask = accomm == frs_val
134- if mask .sum () == 0 : continue
137+ if mask .sum () == 0 :
138+ continue
135139 imp = _wmean (elec [mask ], w [mask ])
136140 rows .append ((frs_val , imp , target , abs (imp - target ) / target ))
137141 _check ("Electricity £/yr by accommodation type (excl. OTHER)" , rows )
@@ -143,7 +147,8 @@ def test_gas_by_accommodation(arrays):
143147 for frs_val , need_key in ACCOMM_TO_NEED .items ():
144148 target = NEED_ACCOMM_GAS [need_key ] * OFGEM_Q4_2023_GAS_RATE
145149 mask = accomm == frs_val
146- if mask .sum () == 0 : continue
150+ if mask .sum () == 0 :
151+ continue
147152 imp = _wmean (gas [mask ], w [mask ])
148153 rows .append ((frs_val , imp , target , abs (imp - target ) / target ))
149154 _check ("Gas £/yr by accommodation type (excl. OTHER)" , rows )
@@ -155,7 +160,8 @@ def test_electricity_by_region(arrays):
155160 for reg , target_kwh in NEED_REGION_ELEC .items ():
156161 target = target_kwh * OFGEM_Q4_2023_ELEC_RATE
157162 mask = region == reg
158- if mask .sum () == 0 : continue
163+ if mask .sum () == 0 :
164+ continue
159165 imp = _wmean (elec [mask ], w [mask ])
160166 rows .append ((reg , imp , target , abs (imp - target ) / target ))
161167 _check ("Electricity £/yr by region" , rows )
@@ -167,7 +173,8 @@ def test_gas_by_region(arrays):
167173 for reg , target_kwh in NEED_REGION_GAS .items ():
168174 target = target_kwh * OFGEM_Q4_2023_GAS_RATE
169175 mask = region == reg
170- if mask .sum () == 0 : continue
176+ if mask .sum () == 0 :
177+ continue
171178 imp = _wmean (gas [mask ], w [mask ])
172179 rows .append ((reg , imp , target , abs (imp - target ) / target ))
173180 _check ("Gas £/yr by region" , rows )
0 commit comments