Skip to content

MAINT: Check and format with NPY201#12353

Merged
drammock merged 3 commits intomne-tools:mainfrom
larsoner:npy201
Jan 11, 2024
Merged

MAINT: Check and format with NPY201#12353
drammock merged 3 commits intomne-tools:mainfrom
larsoner:npy201

Conversation

@larsoner
Copy link
Copy Markdown
Member

From the NumPy 2.0 migration guide they mentioned that there is a new ruff rule NPY201, so let's go ahead and enable it. It caught some == where we should have used is in a few places. It also false-alarms on stuff like if x.dtype == float, which we shouldn't change to if x.dtype is float because is does not give the behavior we want:

>>> np.dtype(float) == np.dtype("<f8")
True
>>> float == np.dtype("<f8")
True
>>> float is np.dtype("<f8")
False

so this PR just uses the explicit if x.dtype == np.dtype(float) in those cases.

Comment on lines +476 to +478
# TODO: type is undefined here and only avoids a flake warning because it's
# a builtin!
if type == "meg": # noqa: E721
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Opened #12352 for this

@drammock drammock merged commit eefd179 into mne-tools:main Jan 11, 2024
@drammock drammock deleted the npy201 branch January 11, 2024 20:09
@drammock
Copy link
Copy Markdown
Member

thanks @larsoner

@cbrnr cbrnr mentioned this pull request Jan 15, 2024
snwnde pushed a commit to snwnde/mne-python that referenced this pull request Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants