Skip to content

feat: Add household axes for MTR and earnings variation#131

Open
SakshiKekre wants to merge 1 commit intomainfrom
feat/household-axes-variation
Open

feat: Add household axes for MTR and earnings variation#131
SakshiKekre wants to merge 1 commit intomainfrom
feat/household-axes-variation

Conversation

@SakshiKekre
Copy link
Contributor

Summary

  • Adds optional axes parameter to POST /household/calculate for sweeping a person's input variable across a range (e.g. employment_income from 0 to 200k in 401 steps)
  • Returns all output variables as 401-element arrays instead of scalars, enabling MTR charts and earnings variation charts
  • Removes the frontend's dependency on the v1 API's calculate-full endpoint for variation calculations
  • Axes support added to both local calculation path and Modal functions (UK + US)

Changes

  • New: src/policyengine_api/utils/axes.py — validate, expand DataFrames, reshape output
  • New: tests/test_axes.py — 18 unit tests for axes logic
  • Modified: src/policyengine_api/api/household.pyAxisSpec model, axes field on request, validation, expansion/reshape threading
  • Modified: src/policyengine_api/modal_app.pyaxes param on simulate_household_uk and simulate_household_us

Test plan

  • Unit tests for expand/reshape/validate logic (18 tests passing)
  • Integration test: POST to /household/calculate with axes, poll, verify 401-element arrays
  • Smoke test: Point alpha FE householdVariation.ts at v2 endpoint, verify MTR + earnings variation charts render

Add axes parameter to /household/calculate endpoint enabling the frontend
to sweep a person's input variable (e.g. employment_income) across a range
and receive 401-point arrays for all output variables. This powers MTR
charts and earnings variation charts, removing the frontend's dependency
on the v1 API's calculate-full endpoint.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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