pydata / xarray

N-D labeled arrays and datasets in Python
https://xarray.dev
Apache License 2.0
3.49k stars 1.04k forks source link

Change np.core.defchararray to np.char (#9165) #9166

Closed pont-us closed 6 days ago

pont-us commented 1 week ago

Replace a reference to np.core.defchararray with np.char.chararray in xarray.testing.assertions, since the former no longer works on NumPy 2.0.0 and the latter is the "preferred alias" according to NumPy docs. See Issue #9165.

welcome[bot] commented 1 week ago

Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient. If you have questions, some answers may be found in our contributing guidelines.

pont-us commented 1 week ago

You might also want to add a note to whats-new.rst

I didn't think this would qualify as a "notable" bug fix, but glad to oblige :)

pont-us commented 6 days ago

From a quick look, it appears that the failing Doctests are due to other, unrelated NumPy 2 changes (mainly NEP 51).

keewis commented 6 days ago

yep, this is also fails on main, so you can ignore these.

welcome[bot] commented 6 days ago

Congratulations on completing your first pull request! Welcome to Xarray! We are proud of you, and hope to see you again! celebration gif

max-sixty commented 6 days ago

Thanks @pont-us

(any other changes for numpy 2.0 would be greatly appreciated if you're up for it...)

keewis commented 6 days ago

just FYI, the doctest / rtd will be fixed by #9177, and the normal CI will be fixed by #9136 (we just need to figure out whether using view is a good idea). This leaves us with the pydap plugin test, but since pydap raises an error with numpy>=2 on import there's nothing we can do about this other than disabling in CI and raising an issue on the pydap issue tracker.

max-sixty commented 6 days ago

That's awesome, thanks @keewis !

pont-us commented 6 days ago

Thanks for the help @keewis and thanks for the thanks @max-sixty :). I don't think I'll have time for another PR in the short term, unfortunately, but I plan to at least open issues for one or two other NumPy-2-related surprises that I've come across (if nobody else does first).