Closed
Description
What happened?
I've run the very simple following code :
import numpy as np, xarray as xr
print (np.fix(3.0))
aa = xr.DataArray([3.0])
print (np.fix(aa))
First print is OK. Second print generates a very long error message ending with a RecursionError: maximum recursion depth exceeded
. See log for details.
What did you expect to happen?
Simply print '3.0' .. :-)
Minimal Complete Verifiable Example
import numpy as np, xarray as xr
print (np.fix(3.0))
aa = xr.DataArray([3.0])
print (np.fix(aa))
MVCE confirmation
- Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- Complete example — the example is self-contained, including all data and the text of any traceback.
- Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
- New issue — a search of GitHub Issues suggests this is not a duplicate.
- Recent environment — the issue occurs with the latest version of xarray and its dependencies.
Relevant log output
return apply_array_ufunc(func, *args, dask=dask)
File "/Users/marti/miniforge3/envs/PROD/lib/python3.13/site-packages/xarray/core/computation.py", line 891, in apply_array_ufunc
return func(*args)
File "/Users/marti/miniforge3/envs/PROD/lib/python3.13/site-packages/xarray/core/arithmetic.py", line 83, in __array_ufunc__
return apply_ufunc(
ufunc,
...<8 lines>...
keep_attrs=_get_keep_attrs(default=True),
)
File "/Users/marti/miniforge3/envs/PROD/lib/python3.13/site-packages/xarray/core/computation.py", line 1278, in apply_ufunc
return apply_array_ufunc(func, *args, dask=dask)
File "/Users/marti/miniforge3/envs/PROD/lib/python3.13/site-packages/xarray/core/computation.py", line 873, in apply_array_ufunc
if any(is_chunked_array(arg) for arg in args):
~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/marti/miniforge3/envs/PROD/lib/python3.13/site-packages/xarray/core/computation.py", line 873, in <genexpr>
if any(is_chunked_array(arg) for arg in args):
~~~~~~~~~~~~~~~~^^^^^
File "/Users/marti/miniforge3/envs/PROD/lib/python3.13/site-packages/xarray/namedarray/pycompat.py", line 92, in is_chunked_array
return is_duck_dask_array(x) or (is_duck_array(x) and hasattr(x, "chunks"))
~~~~~~~~~~~~~~~~~~^^^
File "/Users/marti/miniforge3/envs/PROD/lib/python3.13/site-packages/xarray/namedarray/utils.py", line 90, in is_duck_dask_array
return is_duck_array(x) and is_dask_collection(x)
~~~~~~~~~~~~~~~~~~^^^
File "/Users/marti/miniforge3/envs/PROD/lib/python3.13/site-packages/xarray/namedarray/utils.py", line 69, in is_dask_collection
return is_dask_collection(x)
RecursionError: maximum recursion depth exceeded
Anything else we need to know?
No response
Environment
------------------
commit: None
python: 3.13.1 | packaged by conda-forge | (main, Dec 5 2024, 08:44:03) [Clang 18.1.8 ]
python-bits: 64
OS: Darwin
OS-release: 24.1.0
machine: arm64
processor: arm
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.14.4
libnetcdf: 4.9.2
xarray: 2024.11.0
pandas: 2.2.3
numpy: 2.1.3
scipy: 1.14.1
netCDF4: 1.7.2
pydap: None
h5netcdf: None
h5py: None
zarr: None
cftime: 1.6.4
nc_time_axis: 1.4.1
iris: None
bottleneck: None
dask: 2024.12.0
distributed: 2024.12.0
matplotlib: 3.9.3
cartopy: 0.24.0
seaborn: 0.13.2
numbagg: None
fsspec: 2024.10.0
cupy: None
pint: 0.24.4
sparse: None
flox: None
numpy_groupies: None
setuptools: 75.6.0
pip: 24.3.1
pytest: 8.3.4
mypy: None
IPython: 8.30.0
sphinx: 8.1.3