Skip to content

Conversation

@mscheltienne
Copy link
Contributor

x-ref: mne-tools/mne-python#13585

Fixes:

/opt/hostedtoolcache/Python/3.14.2/x64/lib/python3.14/site-packages/nitime/utils.py:759: in tapered_spectra
    t_spectra.shape = rest_of_dims + (K, NFFT)
    ^^^^^^^^^^^^^^^
E   DeprecationWarning: Setting the shape on a NumPy array has been deprecated in NumPy 2.5.
E   As an alternative, you can create a new view using np.reshape (with copy=False if needed).

And other occurrences.

@mscheltienne
Copy link
Contributor Author

Needs the same cmopatibility function as MNE for numpy < 2.1.

@mscheltienne
Copy link
Contributor Author

This should be better, it adds however packaging as a dependency which should be harmless and provides better version comparison than manual string parsing.

Copy link
Collaborator

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

Looks good to me but I'll let @effigies merge if he's happy!

@effigies
Copy link
Member

In #205 we settled on using SPEC 0, which says we should be dropping numpy<2 now anyway. I think we can get rid of all the compat stuff and just use the numpy 2 features. The minimum nibabel following SPEC 0 rules would be 5.3 (see https://github.com/nipreps/speczeroplus/blob/main/spec-0000/chart.md).

@mscheltienne
Copy link
Contributor Author

However, this requires numpy 2.1.

@larsoner
Copy link
Collaborator

@mscheltienne I think @effigies is suggesting removing some of the existing shims (some of which were slightly tweaked here anyway) while you're messing around with this code

@mscheltienne
Copy link
Contributor Author

Happy to remove the other elements which are in for numpy < 2 and to then bump the pin to 2.0+.

@effigies
Copy link
Member

As to reshape, let's just use a = a.reshape(newshape). The default behavior is to create a view if at all possible, which it should be in all of these cases.

@mscheltienne
Copy link
Contributor Author

@effigies Done! numpy 2.0+, compatibiltiy code gone, and simpler a = a.reshape(newshape) with fallback of copy=None (default).

@effigies effigies merged commit 7f117d6 into nipy:master Jan 13, 2026
17 checks passed
@mscheltienne mscheltienne deleted the fix-deprecation-numpy-2.5 branch January 13, 2026 13:15
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.

3 participants