Skip to content

Fix microsim skill: warn against np.array() and entity-level mismatches#107

Merged
nwoodruff-co merged 1 commit intomainfrom
fix-microsim-entity-mismatch-bug
Mar 8, 2026
Merged

Fix microsim skill: warn against np.array() and entity-level mismatches#107
nwoodruff-co merged 1 commit intomainfrom
fix-microsim-entity-mismatch-bug

Conversation

@MaxGhenis
Copy link
Contributor

Summary

  • Strengthen warnings in the microsimulation skill against using np.array() on MicroSeries, which strips both weights AND entity context
  • Add explicit entity-level mismatch warning with concrete example (tax_unit 23K rows vs household 15K rows)
  • Note that household_net_income includes state tax effects; add income_tax pattern for federal-only scoring

Bug this prevents

When analyzing WATCA, np.array() was used to convert MicroSeries to numpy. A tax_unit-level income_tax array (23K rows) was indexed with a boolean mask, then matched against household_weight (15K rows). Numpy didn't error — it silently gave wrong counts (1K losers instead of 719K).

Test plan

  • Skill loads correctly
  • CI passes

Generated with Claude Code

Real bug encountered: np.array() on MicroSeries strips entity context,
allowing silent mismatches between tax_unit (23K rows) and household
(15K rows) arrays. Boolean mask from one entity applied to weights from
another gives silently wrong counts (showed 1K losers instead of 719K).

Changes:
- Expand CRITICAL section to warn against np.array() specifically (not
  just .values), explaining entity mismatch as the primary danger
- Add entity-level matching section with wrong/right examples
- Note that household_net_income includes state tax effects and add
  federal-only pattern using income_tax for scoring federal bills

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nwoodruff-co nwoodruff-co merged commit 0321ca2 into main Mar 8, 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.

2 participants