Fix microsim skill: warn against np.array() and entity-level mismatches#107
Merged
nwoodruff-co merged 1 commit intomainfrom Mar 8, 2026
Merged
Fix microsim skill: warn against np.array() and entity-level mismatches#107nwoodruff-co merged 1 commit intomainfrom
nwoodruff-co merged 1 commit intomainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
np.array()on MicroSeries, which strips both weights AND entity contexthousehold_net_incomeincludes state tax effects; addincome_taxpattern for federal-only scoringBug this prevents
When analyzing WATCA,
np.array()was used to convert MicroSeries to numpy. A tax_unit-levelincome_taxarray (23K rows) was indexed with a boolean mask, then matched againsthousehold_weight(15K rows). Numpy didn't error — it silently gave wrong counts (1K losers instead of 719K).Test plan
Generated with Claude Code