Change np.core.defchararray to np.char (#9165)#9166
Conversation
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 pydata#9165.
|
Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient. |
There was a problem hiding this comment.
Thanks for the fix, @pont-us.
Could you add a test to make sure we don't regress, please? This could be as simple as adding another parameter set to
xarray/xarray/tests/test_assertions.py
Lines 39 to 61 in 872c1c5
xarray/xarray/tests/test_assertions.py
Lines 33 to 36 in 872c1c5
You might also want to add a note to whats-new.rst
... in assertions._decode_string_data. See pydata#9166.
I didn't think this would qualify as a "notable" bug fix, but glad to oblige :) |
keewis
left a comment
There was a problem hiding this comment.
looks good to me, just one small nit.
Co-authored-by: Justus Magin <keewis@users.noreply.github.com>
|
From a quick look, it appears that the failing Doctests are due to other, unrelated NumPy 2 changes (mainly NEP 51). |
|
yep, this is also fails on |
|
Thanks @pont-us (any other changes for numpy 2.0 would be greatly appreciated if you're up for it...) |
|
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 |
|
That's awesome, thanks @keewis ! |
|
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). |
* main: promote floating-point numeric datetimes to 64-bit before decoding (pydata#9182) also pin `numpy` in the all-but-dask CI (pydata#9184) temporarily remove `pydap` from CI (pydata#9183) temporarily pin `numpy<2` (pydata#9181) Change np.core.defchararray to np.char (pydata#9165) (pydata#9166) Fix example code formatting for CachingFileManager (pydata#9178) Slightly improve DataTree repr (pydata#9064) switch to unit `"D"` (pydata#9170) Docs: Add page with figure for navigating help resources (pydata#9147) Add test for pydata#9155 (pydata#9161) Remove mypy exclusions for a couple more libraries (pydata#9160) Include numbagg in type checks (pydata#9159) Improve zarr chunks docs (pydata#9140)

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.
whats-new.rst