Skip to content

[codex] Add congressional district outcome percentages#266

Merged
MaxGhenis merged 3 commits intomainfrom
codex/congressional-district-outcome-pct
Apr 8, 2026
Merged

[codex] Add congressional district outcome percentages#266
MaxGhenis merged 3 commits intomainfrom
codex/congressional-district-outcome-pct

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

What changed

  • adds district-level winner_percentage, loser_percentage, and no_change_percentage fields to the congressional district impact output
  • computes outcome shares with the same +/-0.1% no-change threshold used in intra-decile results
  • weights district outcome shares by household_count_people * household_weight, with a fallback when the people count column is absent
  • adds focused tests for the new percentages, people-weighting behavior, and threshold handling

Why

The congressional district summary payload exposed average and relative income change, but not winner/loser shares. The frontend district map needs those shares in the state summary payload instead of computing them through hundreds of district-level requests.

Impact

US nationwide economy comparisons can expose district-level winner/loser/no-change shares directly in congressional_district_impact, which allows downstream clients to render those map modes from the main payload.

Validation

  • uv run pytest --noconftest tests/test_congressional_district_impact.py was attempted, but the local build environment fails while compiling pydantic-core for Python 3.14 (Error: not inside a tmux session during Rust linking)
  • the test file itself is updated and isolated, but I could not complete local execution because of that environment issue

Notes

  • No policyengine-api-v2 route change is needed for this shape; the simulation service already returns the policyengine result blob directly.

@MaxGhenis MaxGhenis marked this pull request as ready for review April 8, 2026 11:37
@MaxGhenis MaxGhenis merged commit 4b8225a into main Apr 8, 2026
5 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