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

NumPy 2 support #165

Closed
jni opened this issue Jun 8, 2024 · 3 comments
Closed

NumPy 2 support #165

jni opened this issue Jun 8, 2024 · 3 comments

Comments

@jni
Copy link

jni commented Jun 8, 2024

Tensorstore is not currently compatible with NumPy 2.0, slated to be released on Jun 16. If I create an environment with Python 3.12, NumPy 2.0.0rc2, and TensorStore 0.1.60:

$ pip list
Package     Version
----------- --------
ml-dtypes   0.4.0
numpy       2.0.0rc2
pip         24.0
setuptools  70.0.0
tensorstore 0.1.60
wheel       0.43.0

then run python -c "import tensorstore", I get the following error:

Traceback (most recent call last):  File "<string>", line 1, in <module>
  File "/Users/jni/micromamba/envs/np2/lib/python3.12/site-packages/tensorstore/__init__.py", line 19, in <module>
    from ._tensorstore import *
Traceback (most recent call last):
  File "/Users/jni/micromamba/envs/np2/lib/python3.12/site-packages/numpy/core/_multiarray_umath.py", line 44, in __getattr__
    raise ImportError(msg)
ImportError:
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0rc2 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

I couldn't find any reference to this in the repo so thought I'd flag it here so it's on the team's radar. On our end (napari) we can skip tensorstore tests if numpy >=2 is installed, but of course we'd love to have ts compatible with np2! 🙏

@laramiel
Copy link
Collaborator

Actually not fixed. Will push another commit soon to handle API differences with NumPy2 once it completes internal CI.

@laramiel laramiel reopened this Jun 11, 2024
@jni
Copy link
Author

jni commented Jun 12, 2024

Awesome, thanks @laramiel!

jni pushed a commit to napari/napari that referenced this issue Jun 13, 2024
# References and relevant issues
I don't see a tracking issue for numpy 2.0 support, but here are some
previous PRs I've found:
#6932
#6776

And a zulip thread:

https://napari.zulipchat.com/#narrow/stream/212875-general/topic/handling.20the.20numpy.202.2E0.20release/near/381330412

# Description
This fixes a few more numpy-2.0 related issues. I will comment on some
of them inline.

I tested locally using [a wheel from my vispy
PR](https://github.com/vispy/vispy/actions/runs/9424977460?pr=2599). I
also uninstalled `tensorstore` to skip related tests (see
google/tensorstore#165).

There are still a few test failures in
`napari/layers/image/_tests/test_image.py` that look possibly related to
Xarray:
```
napari/layers/image/_tests/test_image.py:649 test_image_scale[scale5] - DeprecationWarning: __array__ implementation doesn't accept a copy keyword, so passing copy=False failed. __array__ must implement 'dtype' and… [1012/3861]
```

I also get a failure on
`napari/_qt/widgets/_tests/test_qt_tooltip.py::test_qt_tooltip_label`,
but I think this may be a macOS thing (it passes if I mouse over it).

Other than that, local tests with `pytest napari` are all green.
@laramiel
Copy link
Collaborator

I am tagging v0.1.62 which is now compiled with numpy2 support.

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