Add tests for NumPy random seed overflow fix#382
Merged
MaxGhenis merged 8 commits intoPolicyEngine:masterfrom Jul 24, 2025
Merged
Add tests for NumPy random seed overflow fix#382MaxGhenis merged 8 commits intoPolicyEngine:masterfrom
MaxGhenis merged 8 commits intoPolicyEngine:masterfrom
Conversation
Ensure random seeds are always non-negative by wrapping with abs() and int(). This prevents ValueError when large entity IDs cause integer overflow in seed calculation with NumPy 2.1.0's stricter validation. The issue occurs in policyengine-uk tests where the random() function calculates seeds as id * 100 + count, which can overflow for large IDs.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #382 +/- ##
==========================================
+ Coverage 80.67% 81.14% +0.46%
==========================================
Files 194 197 +3
Lines 10036 10228 +192
Branches 1057 1057
==========================================
+ Hits 8097 8299 +202
+ Misses 1651 1640 -11
- Partials 288 289 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Test handling of large entity IDs that would cause overflow - Test consistency of random values for same inputs - Test proper call count incrementing - Test handling of negative IDs - Test specific overflow scenario that would cause ValueError without fix
- Uses the built-in GITHUB_TOKEN secret to authenticate API requests - Increases rate limit from 60/hour (unauthenticated) to 5000/hour - Prevents intermittent CI failures due to 403 errors when downloading data
- Test between() with various inclusive options - Test is_in() with different data types and edge cases - Improve overall code coverage to pass codecov checks
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.
This PR adds comprehensive test coverage for the NumPy random seed overflow fix that was already merged in commit 7dfc74f.
What this PR does
Adds tests to verify the random seed fix handles:
Context
The actual fix for the NumPy 2.1.0 random seed overflow issue was already merged to master. This PR improves code coverage by adding tests that verify the fix works correctly.
Tests
All new tests pass locally and verify that: