Skip to content

Sum person-level variables to tax-unit level in state output resolver#815

Merged
PavelMakarchuk merged 3 commits intomainfrom
fix-person-level-broadcasting
Apr 6, 2026
Merged

Sum person-level variables to tax-unit level in state output resolver#815
PavelMakarchuk merged 3 commits intomainfrom
fix-person-level-broadcasting

Conversation

@PavelMakarchuk
Copy link
Copy Markdown
Collaborator

Summary

  • Fixes broadcasting ValueError for joint/family filers in states with Person-level credit variables (MT, CO)
  • When a PE variable returns a Person-level array (e.g., 3 values for a 3-person household), sums it to a single tax-unit value instead of crashing
  • Adds unit tests for the aggregation logic and integration tests for MT/MO joint filers

Closes #814

Affected variables

Variable State Output Entity
mt_eitc MT v39 Person (head-only)
mt_elderly_homeowner_or_renter_credit MT v37 Person (head-only)
co_family_affordability_credit CO sctc Person (per-person)

Test plan

  • 5 unit tests for _try_calculate_variable aggregation
  • 3 integration tests for MT/MO joint filers through export_household
  • All 106 existing + new tests pass

🤖 Generated with Claude Code

Fixes #814. Some state variables (e.g., mt_eitc,
mt_elderly_homeowner_or_renter_credit, co_family_affordability_credit)
are defined at the Person entity level in policyengine-us. For joint
or family households with multiple persons, the returned array shape
mismatched the expected tax-unit-level shape, causing a ValueError.

Now detects when a calculated array is longer than expected and sums
person values to produce the tax-unit aggregate.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
policyengine-taxsim Ready Ready Preview, Comment Apr 6, 2026 0:57am

Request Review

Strengthens regression coverage for issue #814 by testing code paths
that directly exercise the person-to-tax-unit summing:
- CO sctc: co_family_affordability_credit (Person, per-child)
- MO v36: mo_taxable_income (Person, separate filing)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@PavelMakarchuk PavelMakarchuk marked this pull request as ready for review April 6, 2026 13:15
@PavelMakarchuk PavelMakarchuk merged commit 167c54c into main Apr 6, 2026
12 checks passed
@PavelMakarchuk PavelMakarchuk deleted the fix-person-level-broadcasting branch April 6, 2026 13:15
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.

MO unknown inputs

1 participant