Skip to content

replace np.in1d with np.isin#641

Merged
candytaco merged 2 commits into
mainfrom
in1d-isin
May 19, 2026
Merged

replace np.in1d with np.isin#641
candytaco merged 2 commits into
mainfrom
in1d-isin

Conversation

@candytaco
Copy link
Copy Markdown
Contributor

in1d was deprecated in numpy 2.0 in favor of isin and removed in numpy 2.4.0.

Also updated requirements.txt and pypoject.toml to specify numpy>=1.13.0, when isin was first introduced.

Copilot AI review requested due to automatic review settings May 18, 2026 21:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Replaces deprecated np.in1d calls with np.isin (deprecated in NumPy 2.0, removed in 2.4.0) and pins numpy>=1.13.0 (when np.isin was introduced) in build/runtime requirements.

Changes:

  • Swap np.in1dnp.isin in four modules.
  • Pin numpy>=1.13.0 in requirements.txt and pyproject.toml.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
requirements.txt Pin numpy>=1.13.0 for runtime.
pyproject.toml Pin numpy>=1.13.0 for build requirements.
cortex/utils.py Replace two np.in1d calls with np.isin.
cortex/surfinfo.py Replace np.in1d with np.isin in list comprehension.
cortex/segment.py Replace np.in1d with np.isin in flatten_slim.
cortex/rois.py Replace two np.in1d calls with np.isin.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the deprecated np.in1d function with np.isin across several modules and updates the project's dependencies to require NumPy 1.13.0 or higher. The review feedback correctly identifies opportunities to simplify the code by removing redundant .reshape() and .flatten() calls, as np.isin preserves the shape of the input array unlike its predecessor.

Comment thread cortex/rois.py Outdated
Comment thread cortex/utils.py Outdated
`isin` preserves shapes of original array

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@candytaco candytaco merged commit 6fe15c3 into main May 19, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants