-
Notifications
You must be signed in to change notification settings - Fork 10
Adding test (and variables) for sparse matrix building logic #475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
baogorek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi María,
Nice job on this so far. We should be able to get it merged before stand-up. Please see the comments sprinkled throughout. Here is the big one that could reduce the lines of code substantially:
The TestNationalLevelContributions class (lines 466-656) tests something new and valuable - that national-level targets receive contributions from
households across multiple states without geographic bias. This should stay.
However, TestStateLevelValues and TestCrossStateRecalculation substantially overlap with the existing test_same_state.py and test_cross_state.py. Could we
either:
1. Remove the redundant test classes and rely on the existing tests, or
2. If the new tests add coverage the existing tests miss (e.g., testing more variables), consolidate by extending the existing test files rather than
duplicating the approach?
This would reduce the file from ~875 lines to ~300 lines (just configuration, fixtures, helpers, basic structure tests, and TestNationalLevelContributions).
Feel free to get a second opinion on that.
I was puzzled at first by the number of files in the PR but the black "2026 stable style" was released 4 days ago, so your PR gets to be the one to bring in those changes!
policyengine_us_data/tests/test_local_area_calibration/test_sparse_matrix_builder.py
Outdated
Show resolved
Hide resolved
policyengine_us_data/tests/test_local_area_calibration/test_sparse_matrix_builder.py
Outdated
Show resolved
Hide resolved
policyengine_us_data/tests/test_local_area_calibration/test_sparse_matrix_builder.py
Outdated
Show resolved
Hide resolved
policyengine_us_data/tests/test_local_area_calibration/test_sparse_matrix_builder.py
Outdated
Show resolved
Hide resolved
policyengine_us_data/tests/test_local_area_calibration/test_sparse_matrix_builder.py
Outdated
Show resolved
Hide resolved
policyengine_us_data/tests/test_local_area_calibration/test_matrix_national_variation.py
Show resolved
Hide resolved
|
Sorry I missed the other tests and fixtures. Thank you for pointing me to them! I have removed the redundant tests as you suggested and renamed my file to test_matrix_national_variations.py as the tests became more specific to that. I also took a look at the already existing test_same_state and test_cross_state and made them a bit more flexible so that they automatically consider any new variables we add to conftest.py rather than only checking for snap. Let me know if I missed anything. Otherwise, I think its ready to merge. |
baogorek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
- Reduce VARIABLES_TO_TEST to 3 representative variables (snap, income_tax, eitc) - Reduce COMBINED_FILTER_CONFIG to minimal subset for fast CI runs - Reduce N_VERIFICATION_SAMPLES from 2000 to 500 - Revert test_cds to original 4 states (NC, HI, MT, AK) instead of 8 states Tests now complete in ~4 minutes instead of 3+ hours. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
@juaristi22 the tests were running for 3+ hours so I had to pull this back some. Here's an explanation: |
Fix #472