Fix NumPy 2.x compatibility: replace removed np.in1d with np.isin - #3054
Merged
Conversation
np.in1d was deprecated in NumPy 1.25 and removed from the main namespace in NumPy 2.x, but pyproject.toml pins numpy>=2. Several core functions therefore raise 'AttributeError: module numpy has no attribute in1d' on a supported NumPy version, breaking e.g. find_nearby_pores, site/bond percolation cluster filtering and neighbor queries. Replace the remaining np.in1d call sites with np.isin, the documented drop-in replacement (identical semantics for 1-D inputs, including the invert= keyword). The codebase already uses np.isin elsewhere, so this also unifies the idiom.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev #3054 +/- ##
=====================================
Coverage 87.8% 87.8%
=====================================
Files 151 151
Lines 8882 8882
=====================================
Hits 7804 7804
Misses 1078 1078 🚀 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.
I am trying to get the CI to run on the PR. I cannot seem to make it happen on the PR from @gaoflow's PR, so I created a new branch and pushed it.