Repository navigation
Conversation
NumPy 2.4 removed several APIs that surfa still uses, and NumPy 2.x warns
about others:
- io/framed.py: np.in1d was removed in NumPy 2.4, so saving an
Overlay as a FreeSurfer annotation raised AttributeError. Use
np.isin (available since NumPy 1.13).
- transform/affine.py: the `newshape` keyword of np.reshape was
removed in NumPy 2.4, so Affine.to_warp() raised TypeError. Pass the
shape positionally.
- core/framed.py, transform/affine.py: FramedArray.__array__ and
Affine.__array__ did not accept the `dtype`/`copy` arguments that
NumPy 2 passes, which triggers a DeprecationWarning on every
np.array()/np.asarray() call with copy or dtype. Implement the NumPy 2
protocol: honour dtype, copy=True returns a copy, copy=False raises
if a copy would be required, copy=None copies only when needed.
- core/framed.py: FramedArray.onehot assigned to ndarray.shape, which
is deprecated in NumPy 2.5 (DeprecationWarning); use
np.reshape.
All changes are backwards compatible with NumPy 1.x.
Extends test/test_numpy_compat.py with regression tests for each item
(run with -W error::DeprecationWarning).
Originally committed in the inhuszar/surfa fork as 9d73f7f ("NumPy 2.4
deprecation fixes", meshmind prerequisites checkout).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit afbae5b)
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.
NumPy 2.4 removed several APIs that surfa still uses, and NumPy 2.x warns about others:
newshapekeyword of np.reshape was removed in NumPy 2.4, so Affine.to_warp() raised TypeError. Pass the shape positionally.dtype/copyarguments that NumPy 2 passes, which triggers a DeprecationWarning on every np.array()/np.asarray() call with copy or dtype. Implement the NumPy 2 protocol: honour dtype, copy=True returns a copy, copy=False raises if a copy would be required, copy=None copies only when needed.All changes are backwards compatible with NumPy 1.x.
Extends test/test_numpy_compat.py with regression tests for each item (run with -W error::DeprecationWarning).