What is missing
Since #565 (6.2.3), the UK nation regions filter the stored household region column, and countries/uk/regions.py lists which regions make up each nation (ENGLISH_REGIONS; one region each for Scotland, Wales and Northern Ireland). policyengine-uk keeps its own copy of that mapping in the country formula (variables/household/demographic/country.py), which derives country from region.
No test checks that the two agree. If policyengine-uk changed its Region enum or its country formula, the nation filters would keep households that policyengine-uk places in another nation, and nothing would fail.
Check on the certified data (2026-10-08, main at 07bae75, policyengine-uk 2.102.3)
On enhanced_frs_2024_25_year_2026.h5 (52,846 households), each nation filter keeps exactly the households that policyengine-uk's country assigns to that nation:
| region |
households |
weighted households |
| country/england |
37,961 |
26,354,698.47 |
| country/scotland |
5,405 |
2,729,247.77 |
| country/wales |
3,821 |
1,590,754.53 |
| country/northern_ireland |
5,659 |
783,847.56 |
The four sets are disjoint and cover the file (31,458,548.32 weighted households). Simulation(..., scoping_strategy=country/scotland).run() returns the same 5,405 households and leaves the caller's tables unchanged. #565 noted that the certified artifact was unvalidated, so this closes that gap.
Proposed
Tests that compute policyengine-uk's country for every value of its Region enum (UNKNOWN included) and require each registry nation filter to keep exactly the regions policyengine-uk places in that nation. Add a property over random region-only datasets and an end-to-end Simulation.run() for each nation. Scoping itself stays as #565 made it: stored region, no model calculation.
What is missing
Since #565 (6.2.3), the UK nation regions filter the stored household
regioncolumn, andcountries/uk/regions.pylists which regions make up each nation (ENGLISH_REGIONS; one region each for Scotland, Wales and Northern Ireland). policyengine-uk keeps its own copy of that mapping in thecountryformula (variables/household/demographic/country.py), which derivescountryfromregion.No test checks that the two agree. If policyengine-uk changed its
Regionenum or itscountryformula, the nation filters would keep households that policyengine-uk places in another nation, and nothing would fail.Check on the certified data (2026-10-08, main at 07bae75, policyengine-uk 2.102.3)
On
enhanced_frs_2024_25_year_2026.h5(52,846 households), each nation filter keeps exactly the households that policyengine-uk'scountryassigns to that nation:The four sets are disjoint and cover the file (31,458,548.32 weighted households).
Simulation(..., scoping_strategy=country/scotland).run()returns the same 5,405 households and leaves the caller's tables unchanged. #565 noted that the certified artifact was unvalidated, so this closes that gap.Proposed
Tests that compute policyengine-uk's
countryfor every value of itsRegionenum (UNKNOWN included) and require each registry nation filter to keep exactly the regions policyengine-uk places in that nation. Add a property over random region-only datasets and an end-to-endSimulation.run()for each nation. Scoping itself stays as #565 made it: storedregion, no model calculation.