Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Bug with NumPy 2.0 #1318

Open
larsoner opened this issue Apr 22, 2024 · 3 comments
Open

BUG: Bug with NumPy 2.0 #1318

larsoner opened this issue Apr 22, 2024 · 3 comments

Comments

@larsoner
Copy link
Contributor

Seen on latest MNE-Python CIs

https://github.com/mne-tools/mne-python/actions/runs/8771722469/job/24069839865?pr=12556#step:17:14956

mne/_freesurfer.py:88: in _reorient_image
    orig_data = np.array(img.dataobj).astype(np.float32)
E   DeprecationWarning: __array__ implementation doesn't accept a copy keyword, so passing copy=False failed. __array__ must implement 'dtype' and 'copy' keyword arguments.

This is probably a dup in some form of #1303 , but now that 2.0 is in the brief RC period (a few weeks left I think before release since RC landed a few weeks ago?) figured I'd open a proper issue to track it.

@effigies
Copy link
Member

effigies commented Apr 22, 2024

Looks like this is showing up in our CI (dev run: https://github.com/nipy/nibabel/actions/runs/8776832524/job/24080913543):

   nibabel/tests/test_arrayproxy.py::test_get_obj_dtype
    /home/runner/work/nibabel/nibabel/nibabel/tests/test_arrayproxy.py:306: DeprecationWarning: __array__ implementation doesn't accept a copy keyword, so passing copy=False failed. __array__ must implement 'dtype' and 'copy' keyword arguments.
      assert get_obj_dtype(np.array(prox)) == np.dtype('float64')
  
  nibabel/tests/test_arrayproxy.py::test_get_obj_dtype
    /home/runner/work/nibabel/nibabel/nibabel/tests/test_arrayproxy.py:310: DeprecationWarning: __array__ implementation doesn't accept a copy keyword, so passing copy=False failed. __array__ must implement 'dtype' and 'copy' keyword arguments.
      assert get_obj_dtype(np.array(prox)) == np.dtype('int16')
  
  nibabel/tests/test_arrayproxy.py::test_get_unscaled
    /home/runner/work/nibabel/nibabel/nibabel/tests/test_arrayproxy.py:333: DeprecationWarning: __array__ implementation doesn't accept a copy keyword, so passing copy=False failed. __array__ must implement 'dtype' and 'copy' keyword arguments.
      assert_array_almost_equal(np.array(prox), arr * 2.1 + 3.14)

Should help track it down. Does your group have any time to work on this?

@larsoner
Copy link
Contributor Author

Based on your previous comment here:

Also, the type checking for the updated types will only work if mypy and numpy 2.0-dev are installed into the same environment. I think we're going to need to see if we can drop our custom ArrayLike protocol and use numpy's directly. I can't immediately see another way to work with types that differ between stable and dev versions.

Sounds like the changes are a bit too deep for me I think ☹️

@effigies
Copy link
Member

Ugh... I wonder if we should just have a final pre-2.0 release, and then plan to jump to numpy>=2 for the next release. People who need to use older numpy can just use an older nibabel.

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

No branches or pull requests

2 participants