Add dimension guards for ORG hourly_wage imputation#676
Merged
Conversation
Prevent hourly_wage and other ORG variables from being stored with wrong dimensions (e.g. ORG donor count instead of CPS person count) by adding validation checks at every stage of the pipeline: - predict_org_features: assert output matches receiver frame size - add_org_labor_market_inputs: assert predictions match CPS person count - _splice_cps_only_predictions: assert predictions match entity half-size - _impute_org (source_impute): assert predictions match person count - CPS.downsample: drop unknown variables instead of keeping stale arrays Closes #675 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Pushed a follow-up commit that broadens this fix beyond the original CPS-only patch. What changed:
I also filed #677 for the remaining release-contract work: exact |
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
hourly_wage(and other ORG variables) from being stored with the wrong number of entriesCPS.downsample()to drop variables unknown to the current policyengine-us instead of silently keeping stale (un-downsampled) arraysCloses #675
Context
enhanced_cps_2024.h5on HuggingFace hashourly_wagewith 284,250 entries (the raw ORG donor row count) instead of matching the person count in the simulation. This causes aValueErrorinMicrosimulation()that blocks CI for all open PRs on policyengine-us.Changes
Dimension guards (4 files)
org.py: predict_org_features()cps.py: add_org_labor_market_inputs()extended_cps.py: _splice_cps_only_predictions()source_impute.py: _impute_org()Downsample fix
CPS.downsample()previously kept un-downsampled arrays for variables not recognized by the current policyengine-us (viacontinue). Now it drops them, preventing dimension mismatches when new input variables are added.Test plan
test_org.pytests passtest_extended_cps.pytests passenhanced_cps_2024.h5and verifyhourly_wagehas correct dimensions🤖 Generated with Claude Code