Skip to content

Drop x and y from the UK area lists and from constituency and local-authority results - #727

Draft
anth-volk wants to merge 2 commits into
mainfrom
chore/uk-area-lists-without-xy
Draft

anth-volk wants to merge 2 commits into
mainfrom
chore/uk-area-lists-without-xy

Conversation

@anth-volk

Copy link
Copy Markdown
Contributor

Fixes #726

Merge requirement: merge only after PolicyEngine/policyengine-sim-api#919 is deployed. Until then the simulation API's executor reads x and y from .py's constituency list (_uk_constituency_lookup in simulation_output_geographic.py) and refuses constituency records without them ("missing lookup coordinates"). This PR also waits until after the UK Budget on 28 October 2026.

Summary

.py's constituency and local-authority results and its packaged UK area lists no longer carry x and y, each area's integer position on a hex map. The PolicyEngine app places areas on its hex maps from its own layout files, so nothing downstream should depend on positions from .py.

Two commits, each with one behaviour change:

  1. Leave x and y out of constituency and local-authority results. compute_longwise_uk_geography_impacts reads only code and name from the lookup CSV, so the rows of compute_uk_constituency_impacts, compute_uk_local_authority_impacts, ConstituencyImpact and LocalAuthorityImpact have exactly <area>_code, <area>_name, average_household_income_change, relative_household_income_change and population. A lookup CSV passed as constituency_csv_path or local_authority_csv_path may still have x and y columns; they are ignored. _optional_int, used only for the positions, is deleted. The two functions' docstrings and docs/outputs.md and docs/regions.md no longer mention map coordinates.
  2. Remove the x and y columns from the packaged area lists. constituencies_2024.csv now has code,name,region,country and local_authorities_2023.csv has code,name. Every row, code, name and the row order are unchanged: I compared each file with origin/main's after dropping x and y (pandas.testing.assert_frame_equal, all values read as strings). SOURCES.md records that the columns were removed and still names the source files and their SHA-256s; the area list comment in uk_geography_assets.py, the UK region module docstring and docs/regions.md no longer describe hex positions.

The changelog fragment is changelog.d/726.removed.md, which makes the next release a minor version. Callers that read x or y from these rows or files lose them; if maintainers treat that as a breaking change, the fragment can be renamed to 726.breaking.md.

Who reads these files and fields

Deployment and environment variables

No CI/CD workflow, Dockerfile, Terraform or other deployment code changes, and no environment variable is added, removed or read differently. The only packaged files that change are the two CSVs and SOURCES.md under src/policyengine/data/uk_geography/.

Testing

Written red-green: for each commit the tests were written first and seen failing for the expected reason, then the code was written and both were committed together.

  • Commit 1: six tests in tests/test_constituency_impact.py and tests/test_local_authority_impact.py now require each result row to have exactly the five keys above, with a custom lookup that has x and y, with the packaged list, and with no lookup. All six failed with Extra items in the left set: 'x', 'y'.
  • Commit 2: tests/test_uk_area_lists.py requires each list's header to be exactly its expected columns, and drops the check that no two areas share a hex. Both parametrised cases failed because the headers still had x and y (['code', 'name', 'x', 'y'] == ['code', 'name']).

Commands run locally:

  • uv run --frozen pytest tests/test_constituency_impact.py tests/test_local_authority_impact.py tests/test_uk_area_lists.py tests/test_uk_regions.py tests/test_disclosure_estimate.py: all pass.
  • ruff format --check . and ruff check . (ruff 0.16.8, as CI installs the latest ruff): pass.
  • uv run --frozen mypy --python-version 3.13 on the changed modules: no new errors (the same 13 existing errors in the output modules before and after).
  • towncrier check --compare-with origin/main and towncrier build --draft: the fragment renders under "Removed".
  • Not run locally: the full test suite, which CI runs.

🤖 Generated with Claude Code

anth-volk and others added 2 commits October 28, 2026 15:37
compute_longwise_uk_geography_impacts no longer copies each area's x and
y hex-map position from the lookup CSV into its result row, so
compute_uk_constituency_impacts, compute_uk_local_authority_impacts,
ConstituencyImpact and LocalAuthorityImpact return rows with only the
code, name, income changes and population. The app places areas on its
hex maps from its own layout files. A lookup CSV passed as
constituency_csv_path or local_authority_csv_path may still have x and y
columns; they are ignored.

Tests first: the result rows of both outputs must have exactly those
keys, whether the lookup is a custom CSV with x and y, the packaged list,
or missing. They failed because every row had extra x and y keys.

Refs #726

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
constituencies_2024.csv now has code,name,region,country and
local_authorities_2023.csv has code,name. Nothing in the package reads
the hex-map positions any more, and the app places areas on its hex maps
from its own layout files. Every row, code, name and the row order are
unchanged, checked by comparing each file with origin/main's after
dropping x and y. SOURCES.md, the area list comment, the UK region
module docstring and the regions docs no longer describe hex positions.

Tests first: each list's header must be exactly its expected columns,
and the check that no two areas share a hex is removed. They failed
because both headers still had x and y.

Refs #726

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drop x and y from the UK area lists and from constituency and local-authority results

1 participant