-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
unstacking an integer array yields a RuntimeWarning after upgrade to numpy 1.24.1 #7423
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
Comments
I just encountered this one as well. It seems the issue is here: xarray/xarray/core/variable.py Lines 1815 to 1820 in 43ba095
fill_value = np.nan and dtype = "int64" .
As mentioned in numpy/numpy#8017 (comment), Can we do anything about that here (besides silencing the warning, but I'm not sure if that actually makes sense), or do we need to lobby for nullable dtypes in Edit: as it seems there are at least 4 deferred NEPs (NEPs 12, 24, 25, and 26) on the topic of missing values this might be more tricky than I expected. So I guess that means that we might have to try finding a workaround. |
Would you consider xarray itself to be "numpy-adjacent"? If XArray fully adopted (i don't know how!) the NetCDF4 |
This new warning has appeared when I call DataSet.unstack(), with xarray 2023.5.0 and numpy 1.24 I suspect this warning is related to the stricter type checking in numpy 1.24. |
I no longer get the warning on numpy 1.26.1 — please reopen if others do |
I see this on numpy 1.26.2 using the MWE (and my own code)
|
@tguruswamy I don't get that on the latest xarray — do you? |
You're right -- 2023.12.0 is ok. Thanks for the pointer! A quick bisect suggests this was solved in v2023.8.0. |
this should have been closed by #8061 |
Agree the issue was resolved with v2023.8.0. |
What happened?
After upgrading numpy from 1.23.5 to 1.24.1, calling the
unstack
method on anxarray.DataArray
with integer data produces the warning<__array_function__ internals>:200: RuntimeWarning: invalid value encountered in cast
. I think this relates to "ongoing work to improve the handling and promotion of dtypes" (Numpy 1.24.0 Release Notes), and is catching the fact that the method attempts to providenan
as a fill value on an integer array.What did you expect to happen?
In the case below, where there is no need for a fill value, I do not expect to get a warning.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
No response
Environment
xarray: 2022.12.0
pandas: 1.5.2
numpy: 1.24.1
scipy: 1.10.0
netCDF4: 1.6.2
pydap: None
h5netcdf: 1.1.0
h5py: 3.7.0
Nio: None
zarr: None
cftime: 1.6.2
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2022.12.1
distributed: None
matplotlib: 3.6.2
cartopy: 0.21.1
seaborn: None
numbagg: None
fsspec: 2022.11.0
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 65.6.3
pip: 22.1.2
conda: None
pytest: None
mypy: None
IPython: 8.8.0
sphinx: None
The text was updated successfully, but these errors were encountered: