Skip to content

Conversation

@anth-volk
Copy link
Collaborator

@anth-volk anth-volk commented Feb 3, 2026

Fixes #3194

Summary

  • Add support for US Census place-level regions with format place/{STATE_ABBREV}-{PLACE_FIPS} (e.g., place/NJ-57000 for Newark, NJ)
  • Remove city region type (city/nyc) in favor of the more comprehensive place regions

Requires PolicyEngine/policyengine.py#223

Changes

Added

  • place/ prefix validation in _validate_us_region:
    • Validates state abbreviation is a valid US state
    • Validates FIPS code is a 5-digit number
  • place/ prefix passthrough in normalize_us_region
  • Updated REGION_PREFIXES and US_REGION_TYPES constants

Removed

  • city/ prefix validation and handling
  • city/nyc from metadata region list
  • Legacy nyccity/nyc normalization

Test plan

  • Verify place validation accepts valid place codes like place/NJ-57000
  • Verify place validation rejects invalid formats
  • Verify place regions use parent state's dataset
  • Run full test suite

Related

🤖 Generated with Claude Code

- Add support for place/ prefix regions with format place/{STATE_ABBREV}-{PLACE_FIPS}
  (e.g., place/NJ-57000 for Newark, NJ)
- Remove city/ prefix and city region type (previously only supported NYC)
- Update _validate_us_region to validate place codes:
  - Validates state abbreviation
  - Validates 5-digit FIPS code format
- Update normalize_us_region to pass through place/ prefix
- Remove city/nyc from metadata region list
- Update all related tests

Fixes #3194

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@anth-volk anth-volk changed the title Fixes #3194: Add place-level region support and remove city region type Add place-level region support and remove city region type Feb 3, 2026
anth-volk and others added 4 commits February 4, 2026 02:58
- Add parse_place_code() to extract state and FIPS from place codes
- Add validate_place_code() for reusable place code validation
- Update _validate_us_region to use the new helpers
- Add comprehensive unit tests for both helper functions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create policyengine_api/data/places.py with parse_place_code and validate_place_code
- Remove place functions from congressional_districts.py
- Update economy_service.py import to use new module
- Create tests/unit/data/test_places.py with dedicated tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Place regions use their parent state's dataset for simulation. Extract
the state abbreviation from the place code and use that to get the
dataset path from get_default_dataset.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.75%. Comparing base (28fd999) to head (f2cd180).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3195      +/-   ##
==========================================
+ Coverage   70.56%   70.75%   +0.19%     
==========================================
  Files          55       56       +1     
  Lines        2388     2397       +9     
  Branches      339      340       +1     
==========================================
+ Hits         1685     1696      +11     
+ Misses        642      641       -1     
+ Partials       61       60       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anth-volk anth-volk marked this pull request as ready for review February 4, 2026 00:34
@anth-volk anth-volk merged commit 5e99824 into master Feb 4, 2026
7 checks passed
@anth-volk anth-volk deleted the add-place-support-remove-city branch February 4, 2026 00:34
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.

Add place-level region support and remove city region type

2 participants