Skip to content

Comments

Phase 3: Expensive computations — output classes#235

Merged
anth-volk merged 6 commits intoapp-v2-migrationfrom
feat/sim-report-migration/phase-3
Feb 20, 2026
Merged

Phase 3: Expensive computations — output classes#235
anth-volk merged 6 commits intoapp-v2-migrationfrom
feat/sim-report-migration/phase-3

Conversation

@anth-volk
Copy link
Contributor

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

Summary

  • Add CongressionalDistrictImpact output class for US per-district income changes
  • Add ConstituencyImpact output class for UK parliamentary constituencies (weight matrix reweighting)
  • Add LocalAuthorityImpact output class for UK local authorities (weight matrix reweighting)
  • Add IntraDecileImpact output class with 5-category income change proportions (people-weighted)
  • Add decile_variable parameter to DecileImpact for pre-computed grouping (wealth deciles)
  • Add household_wealth_decile to UK model entity variables
  • Unit tests for all new output classes (15 tests)

Companion PR: PolicyEngine/policyengine-api-v2-alpha#87 — Phase 3 API wiring

Test plan

  • All 15 new unit tests pass
  • Full existing test suite unaffected
  • Verify integration with API v2 alpha consumption of these classes

🤖 Generated with Claude Code

anth-volk and others added 5 commits February 20, 2026 21:10
Add CongressionalDistrictImpact output that groups households by
congressional_district_geoid and computes per-district weighted average
and relative income changes. Add geoid to US household entity_variables.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds ConstituencyImpact output that reweights households using a
pre-computed weight matrix (parliamentary_constituency_weights.h5)
to compute per-constituency average/relative income change.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds LocalAuthorityImpact output that reweights households using a
pre-computed weight matrix (local_authority_weights.h5) to compute
per-local-authority average/relative income change.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add IntraDecileImpact output class with compute_intra_decile_impacts()
for computing 5-category income change distributions within deciles.
Uses qcut by default for grouping, with decile_variable parameter for
pre-computed groupings (e.g. household_wealth_decile).

Also adds decile_variable parameter to DecileImpact for the same
purpose, and adds household_wealth_decile to UK entity_variables.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add tests for CongressionalDistrictImpact, ConstituencyImpact,
LocalAuthorityImpact, IntraDecileImpact, and DecileImpact with
decile_variable support. Use model_construct() in convenience
functions to bypass Pydantic validation for programmatic construction.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@anth-volk anth-volk marked this pull request as ready for review February 20, 2026 23:23
@anth-volk anth-volk merged commit 6ccb46a into app-v2-migration Feb 20, 2026
2 checks passed
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.

1 participant