Skip to content

Check the UK nation filters against policyengine-uk's country formula #569

Description

@MaxGhenis

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.

Activity

  1. added a commit that references this issue on Oct 9, 2026
    da51cf1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions