-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
testing.assert_allclose on string dtype gives error with NumPy 2.0.0 #9165
Comments
Thanks for the report, @pont-us. Only the most recent version of |
actually, I can reproduce this locally... maybe our tests are not as extensive as I had hoped they are? |
good news is, this can be easily fixed by replacing |
Yes, I'm on |
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.
* Change np.core.defchararray to np.char.chararray (#9165) 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. * Add test for assert_allclose on dtype S (#9165) * Use np.char.decode, not np.char.chararray.decode ... in assertions._decode_string_data. See #9166. * List #9165 fix in whats-new.rst * cross-like the fixed function * Improve a parameter ID in tests.test_assertions Co-authored-by: Justus Magin <keewis@users.noreply.github.com> * whats-new normalization --------- Co-authored-by: Justus Magin <keewis@users.noreply.github.com>
* 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)
What happened?
This error came up in an nc2zarr unit test in a nightly CI run, just after the release of NumPy 2.0.0. This is the test in question, and here is the call to
xarray.testing.allclose
which triggers the error:What did you expect to happen?
We expected that
xarray.testing.allclose
would perform as stated rather than producing an error.Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
Error appears to be due to a failed import of
defchararray
from a path that's no longer valid in NumPy 2.numpy._core.defchararray
says "The preferred alias fordefchararray
isnumpy.char
.". Replacingnp.core.defchararray
withnp.char.chararray
inxarray.testing.assertions
seems to fix it.Environment
INSTALLED VERSIONS
commit: None
python: 3.12.4 | packaged by conda-forge | (main, Jun 17 2024, 10:23:07) [GCC 12.3.0]
python-bits: 64
OS: Linux
OS-release: 5.15.0-107-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: ('en_GB', 'UTF-8')
libhdf5: 1.14.2
libnetcdf: 4.9.3-development
xarray: 0.1.dev5453+g872c1c5
pandas: 2.2.2
numpy: 2.0.0
scipy: 1.13.1
netCDF4: 1.7.1
pydap: None
h5netcdf: 1.3.0
h5py: 3.11.0
zarr: 2.18.2
cftime: 1.6.4
nc_time_axis: 1.4.1
iris: None
bottleneck: 1.4.0
dask: 2024.6.2
distributed: 2024.6.2
matplotlib: 3.9.0
cartopy: None
seaborn: 0.13.2
numbagg: 0.8.1
fsspec: 2024.6.0
cupy: None
pint: None
sparse: None
flox: 0.9.8
numpy_groupies: 0.11.1
setuptools: 70.1.0
pip: 24.0
conda: None
pytest: 8.2.2
mypy: 1.10.0
IPython: 8.25.0
sphinx: None
The text was updated successfully, but these errors were encountered: