fix(segmentation): use np.isin in clear_border (np.in1d removed in numpy ≥2.2)#43
Merged
Merged
Conversation
…mpy ≥2.2) np.in1d was deprecated in numpy 1.25 and removed in numpy 2.2. np.isin is the drop-in replacement; for the 1-D indices array used here the two are behaviorally identical (np.in1d always flattens, np.isin preserves shape, and indices is already 1-D from np.arange). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideReplaces the deprecated and removed NumPy np.in1d call in clear_border with np.isin to maintain compatibility with NumPy ≥2.2 while preserving behavior for the 1-D indices array. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Since
indicesis created withxp.arange, consider using the corresponding backend-specificisin(or keeping this consistently on thexpnamespace) to avoid potential device/array-type mismatches whenxpis not NumPy.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Since `indices` is created with `xp.arange`, consider using the corresponding backend-specific `isin` (or keeping this consistently on the `xp` namespace) to avoid potential device/array-type mismatches when `xp` is not NumPy.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
alxndrkalinin
added a commit
that referenced
this pull request
Jun 1, 2026
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
cubic/segmentation/_clear_border.py:120callsnp.in1d, which was deprecated in numpy 1.25 and removed in numpy 2.2. Replaces withnp.isin, the drop-in successor.For the 1-D
indices = np.arange(number + 1)array used here, the two functions are behaviorally identical (np.in1dalways flattens its output;np.isinpreserves input shape — both produce the same 1-D mask when the input is already 1-D).Test plan
clear_bordertests pass (tests/segmentation/test_clear_border.py)🤖 Generated with Claude Code
Summary by Sourcery
Bug Fixes: