Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

UK local-area exports: add the `constituency_code_oa`, `la_code_oa` and `region_code_oa` columns that policyengine.py and the simulation API read, and record the area-code frames in the release manifest

Chiusa
#1,114 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Una pull request collegata è già stata integrata.

  • #1115 di @juaristi22 — integrata

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Start at graph_terminal._tables and read how UK area-code columns are exported and dropped; then inspect the release manifest metadata and terminal_gates.py. Add a release-contract test for UK releases with area codes. Done means dense and local releases have all three _oa aliases equal to their ladder columns and non-empty for every household, with the area-code frames recorded in the manifest.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Why

policyengine.py finds UK constituencies and local authorities through two household columns, constituency_code_oa and la_code_oa:

  • its constituency and local-authority regions filter on them (countries/uk/regions.py);
  • its constituency and local-authority impact outputs group on them (outputs/constituency_impact.py, outputs/local_authority_impact.py);
  • it copies them, with oa_code, lsoa_code, msoa_code and region_code_oa, into every UK output dataset (UK_HOUSEHOLD_PASSTHROUGH_COLUMNS).

The simulation API reads the same pair for geographic reports (UK_GEOGRAPHIC_DATASET_VARIABLES in policyengine-sim-api's stage12_runtime/output_planning.py). These are the names the incumbent enhanced FRS carries; 1.56.16 has all six.

Our full-build exports carry the ladder names instead: the ladder columns (UK_GEOGRAPHY_LADDER_COLUMNS) leave through graph_terminal._tables, with none of the _oa names. The last staged local candidate (staged/uk-local-candidate-f100-s42-20260919T154920Z-1d33cff6, 55,361 households) has oa_code, lsoa_code, msoa_code, local_authority_code, ward_code, constituency_code, region_code and itl1_code to itl3_code. On a Microcosm file, every constituency or local-authority run in policyengine.py therefore raises Variable 'constituency_code_oa' not found in household data. Renaming on the consumer side would break the enhanced FRS and the API; writing the aliases here keeps every consumer working.

The codes themselves already line up with policyengine.py:

  • Constituencies: the July 2024 Westminster frame, all 650 including Northern Ireland's 18. The enhanced FRS covers the 632 in Great Britain, all shared.
  • Local authorities: the April 2023 LAD frame, 361 codes (LAD23_COUNT).
    • policyengine.py's list (local_authorities_2021.csv, on the same frame despite its name) has 360 of them. It lacks Ards and North Down (N09000011), which PolicyEngine/policyengine.py#553 adds.
    • The enhanced FRS is on the pre-2023 frame: 363 codes in Great Britain, 17 of them for districts abolished in 2023.

Proposed change

  1. Write three alias columns at the single-year export boundary (graph_terminal._tables, where the nation-native aliases are already dropped), on every UK release that carries area codes (the dense and local lines):

    • constituency_code_oa = constituency_code
    • la_code_oa = local_authority_code
    • region_code_oa = region_code

    Keep the ladder columns: our gates, diagnostics and target compilation read them. The _oa suffix is the consumers' name only. Northern Irish households are placed through data zones rather than output areas, and the codes are the same either way. UK_ALLOWED_EXTRA_EXPORT_COLUMNS in terminal_gates.py already admits all three names.

  2. Record the frames in the release manifest's metadata, for example "area_code_frames": {"constituency": "westminster_2024", "local_authority": "lad_2023_04"}. policyengine.py can then check that its area lists match before it wires a local release in. The next frame change to watch is the 1 April 2025 Barnsley/Sheffield recode, which the LAD lookups we pin do not carry yet.

  3. Add a release-contract test: a UK release with area codes carries the three aliases, each equal to its ladder column and non-empty for every household.

The national line needs no change. It carries region only, and policyengine.py will scope nations and regions from region (PolicyEngine/policyengine.py#553).

Done when

  • The next staged dense or local candidate carries the three aliases.
  • policyengine.py's constituency and local-authority row filters find households in all 650 constituencies and all 361 local authorities of that candidate.

Related:

  • PolicyEngine/policyengine.py#553: certifying a Microcosm national dataset in policyengine.py, with separate national and local-area datasets.
  • PolicyEngine/policyengine.py#552: regional dataset defaults.

🤖 Generated with Claude Code

Lingua principale
Python
Stelle
0
Fork
5
Merge medio
1g 19h
PR unite (30g)
115

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PolicyEngine/microcosm

Tutte le issue di PolicyEngine/microcosm

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.