Fix #583: typing issues with numpy 2.5 - #585
Open
thierry-martinez wants to merge 1 commit into
Open
Conversation
This commit fixes the typing issues introduced by numpy 2.5, making the codebase compatible with newer versions of numpy while preserving compatibility with older versions (from numpy 2). numpy 2.5 uses the type alias syntax to define `NDArray`, so we can no longer use `NDArray` as a base type. The issue numpy/numpy#31513 has been fixed, so we can stop ignoring the argument types of `np.einsum`. `rng.choice` is now typed as `signedinteger[_32Bit | _64Bit]` instead of `Any`, so `rng.choice([0, 1])` is no longer a valid `Outcome` value. This commit introduces `rand_outcome` to generate a random `Outcome` value.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #585 +/- ##
=======================================
Coverage 89.26% 89.27%
=======================================
Files 49 49
Lines 7791 7795 +4
=======================================
+ Hits 6955 6959 +4
Misses 836 836 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 commit fixes the typing issues introduced by numpy 2.5, making the codebase compatible with newer versions of numpy while preserving compatibility with older versions (from numpy 2).
numpy 2.5 uses the type alias syntax to define
NDArray, so we can no longer useNDArrayas a base type.The issue numpy/numpy#31513 has been fixed, so we can stop ignoring the argument types of
np.einsum.rng.choiceis now typed assignedinteger[_32Bit | _64Bit]instead ofAny, sorng.choice([0, 1])is no longer a validOutcomevalue. This commit introducesrand_outcometo generate a randomOutcomevalue.