xr.decode_cf()
fails to replace FillValue
with np.nan
with numpy >= 2.0
when data array dtype is np.float32
#9381
Labels
What happened?
Since
numpy >= 2.0
,xr.decode_cf()
fails to replaceFillValue
withnp.nan
when:np.float32
FillValue
attribute is of typefloat
.The issue does not occur for data arrays with dtype
np.float64
.This bug should not affect decoding of dataset opened with
open_dataset
because sincenumpy >= 2.0
, numeric values in the attributes are now directly stored asnp.int<...>
ornp.float32
types instead of the previously usedint
orfloat
types.To keep my code compatible with all numpy versions I currently use:
What did you expect to happen?
xr.decode_cf()
to replace fillvalues withnp.nan
also when theFillValue
attribute is of typefloat
.Minimal Complete Verifiable Example
MVCE confirmation
Environment
xarray: 2024.7.0
pandas: 2.2.2
numpy: 2.0.1
scipy: 1.14.0
netCDF4: 1.7.1
pydap: None
h5netcdf: None
h5py: 3.11.0
zarr: None
cftime: 1.6.4
nc_time_axis: None
iris: None
bottleneck: None
dask: 2024.8.1
distributed: 2024.8.1
matplotlib: 3.9.2
cartopy: 0.23.0
seaborn: None
numbagg: None
fsspec: 2024.6.1
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 72.1.0
pip: 24.2
conda: None
pytest: 8.3.2
mypy: None
IPython: 8.26.0
sphinx: 8.0.2
The text was updated successfully, but these errors were encountered: