Conversation
…ss numpy dtypes directly
…mpy.set_printoptions instead
for more information, see https://pre-commit.ci
|
Status:
As expected, the new ruff linting check is failing until we fix this last napari/utils/_tracebacks.py:37:13: NPY201 `np.set_string_function` will be removed in NumPy 2.0. Use `np.set_printoptions` for custom printing of NumPy objects.
napari/utils/_tracebacks.py:91:17: NPY201 `np.set_string_function` will be removed in NumPy 2.0. Use `np.set_printoptions` for custom printing of NumPy objects.
napari/utils/_tracebacks.py:137:17: NPY201 `np.set_string_function` will be removed in NumPy 2.0. Use `np.set_printoptions` for custom printing of NumPy objects. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6776 +/- ##
==========================================
- Coverage 92.45% 92.41% -0.04%
==========================================
Files 614 614
Lines 55164 55162 -2
==========================================
- Hits 51001 50979 -22
- Misses 4163 4183 +20 ☔ View full report in Codecov by Sentry. |
…r less verbose array printing
…into numpy-v2-compat
|
I've looked into the numpy.set_printoptions docs some more, and I don't think we can reproduce the old behaviour exactly. But I can reduce how verbose the array is in the print output. Is this sufficient, or does anyone have a better plan? arr = np.random.random((512,512))Old: New ( Default (no printoptions settings) |
|
Hi @GenevieveBuckley, I couldn't find how to reproduce the old behavior in numpy 2.0.0. There's a Changing the options to have a smaller output, as you did, might be a good compromise. |
|
This PR looks good to me. |
Yeah, that's what I found too. |
for more information, see https://pre-commit.ci
|
Ready for review |
Czaki
left a comment
There was a problem hiding this comment.
Could we relax constraint <2 on NumPy version (line 52 in pyproject.toml) and run pre-test, or is there a known problem why we cannot test against numpy 2.0?
Sure, we can do that. I've pushed this branch to napari/napari, and set the --pre test workflow running here: https://github.com/napari/napari/actions/runs/9055845357 |
|
There's one failing job from --pre test: I've run the test a second time, same Windows access error. But windows-latest with pyqt5 passes fine, it's only windows with pyqt6 that has this problem. I'll look into it a bit more if I have some time. |
|
I'm not sure if the Windows access error seen above is just a flaky test. I can't reproduce the problem on my fork, and it seems to disappear here when I add the |
|
It is a known problem with pyqt6 and our cleaning mechanism. |
|
Thank you very much for getting this done @GenevieveBuckley!!! I kept seeing the NumPy announcements thinking, really should get onto that... 😅 😬 😂 So I'm super grateful!!! |
# 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.
References and relevant issues
Description
This PR: