[codex] Fix microsim self-employment smoke test#7978
Open
daphnehanse11 wants to merge 1 commit intoPolicyEngine:mainfrom
Open
[codex] Fix microsim self-employment smoke test#7978daphnehanse11 wants to merge 1 commit intoPolicyEngine:mainfrom
daphnehanse11 wants to merge 1 commit intoPolicyEngine:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7978 +/- ##
===========================================
- Coverage 100.00% 92.84% -7.16%
===========================================
Files 1 4212 +4211
Lines 13 60818 +60805
Branches 0 307 +307
===========================================
+ Hits 13 56468 +56455
- Misses 0 4222 +4222
- Partials 0 128 +128
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
baogorek
requested changes
Apr 10, 2026
Collaborator
baogorek
left a comment
There was a problem hiding this comment.
Please see the comment. My robot thinks self_employment_income can be negative whereas employment_income is non-negative, so they should be treated separately.
| # Check that the microsim calculates important variables as nonzero in current year. | ||
| # Self-employment is net business income, so weighted totals can be negative | ||
| # when losses outweigh profits in the sampled records. | ||
| for var in ["employment_income", "self_employment_income"]: |
Collaborator
There was a problem hiding this comment.
My robot is saying that we should split these apart in the list, do .sum() > 0 for employment_income and .abs().sum() > 0 for self_employment_income
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
Why
The failing GitHub Actions job on PR #7977 was not caused by the Texas Medicaid change. It failed in
policyengine_us/tests/microsimulation/test_microsim.pybecause the test assumedself_employment_income.sum() > 0.That assumption is too strict:
self_employment_incomeis modeled as net business income, so weighted losses can outweigh weighted profits in a sampled dataset and produce a negative aggregate total even when the variable is present and working.Root cause
The smoke test was using a positivity check where it really needed a nonzero-magnitude check.
Validation
make formatpython -m py_compile policyengine_us/tests/microsimulation/test_microsim.pyMicroSeries.sum()can be negative whileMicroSeries.abs().sum()remains nonzeroNotes
I could not run the full dataset-backed microsimulation test locally in this sandbox because the Hugging Face datasets are not reachable here, so CI should be the source of truth for the full repro and verification.