What happens
Every UK nation region fails on the certified UK data. country/england, country/scotland, country/wales and country/northern_ireland scope with RowFilterStrategy(variable_name="country", ...) (src/policyengine/countries/uk/regions.py). That filter reads a country column from the input household table. The certified year file does not store one: policyengine-uk derives country from region in a formula.
Reproduced on 2026-10-08 with main at 9663cf2 (policyengine-uk 2.102.3). pe.uk.ensure_datasets(years=[2026]) wrote enhanced_frs_2024_25_year_2026.h5, with 52,846 households. The household table has region, region_code_oa, la_code_oa and constituency_code_oa, but no country. Both of these raise:
region = uk_region_registry.get("country/scotland") # same for country/england
Simulation(dataset=year_2026, tax_benefit_model_version=pe.uk.uk_latest,
scoping_strategy=region.scoping_strategy).run()
ValueError: Variable 'country' not found in household data. Available columns: ['household_id', 'household_weight', 'region', ...]
#553 (section 3) reports the same failure on the Microcosm national file.
Fix
Before scoping, the model version checks the household variables the strategy filters on. If one is missing from the input household table, policyengine-uk calculates it on the unscoped dataset. The derived column is used for the filter only and dropped from the scoped input. policyengine.py then keeps no copy of the region-to-nation mapping: the nations are whatever policyengine-uk's country formula says. A strategy now declares the variables it filters on.
On the 2026 year file, computing country through policyengine-uk takes about 2.7s on the full dataset. It splits the 52,846 households 37,961 England / 5,405 Scotland / 3,821 Wales / 5,659 Northern Ireland, with each region mapped to exactly one nation.
What happens
Every UK nation region fails on the certified UK data.
country/england,country/scotland,country/walesandcountry/northern_irelandscope withRowFilterStrategy(variable_name="country", ...)(src/policyengine/countries/uk/regions.py). That filter reads acountrycolumn from the input household table. The certified year file does not store one: policyengine-uk derivescountryfromregionin a formula.Reproduced on 2026-10-08 with
mainat 9663cf2 (policyengine-uk 2.102.3).pe.uk.ensure_datasets(years=[2026])wroteenhanced_frs_2024_25_year_2026.h5, with 52,846 households. The household table hasregion,region_code_oa,la_code_oaandconstituency_code_oa, but nocountry. Both of these raise:#553 (section 3) reports the same failure on the Microcosm national file.
Fix
Before scoping, the model version checks the household variables the strategy filters on. If one is missing from the input household table, policyengine-uk calculates it on the unscoped dataset. The derived column is used for the filter only and dropped from the scoped input. policyengine.py then keeps no copy of the region-to-nation mapping: the nations are whatever policyengine-uk's
countryformula says. A strategy now declares the variables it filters on.On the 2026 year file, computing
countrythrough policyengine-uk takes about 2.7s on the full dataset. It splits the 52,846 households 37,961 England / 5,405 Scotland / 3,821 Wales / 5,659 Northern Ireland, with each region mapped to exactly one nation.