Skip to content
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

np.fix on a data array produces RecursionError: maximum recursion depth exceeded #9872

Open
5 tasks
oliviermarti opened this issue Dec 10, 2024 · 0 comments
Open
5 tasks
Labels
bug needs triage Issue that has not been reviewed by xarray team member

Comments

@oliviermarti
Copy link

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

@oliviermarti oliviermarti added bug needs triage Issue that has not been reviewed by xarray team member labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs triage Issue that has not been reviewed by xarray team member
Projects
None yet
Development

No branches or pull requests

1 participant