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

'xarray.core' has no attribute 'ops' in xarray 2025.03.0 #2113

Closed
2 tasks done
jensdebruijn opened this issue Mar 20, 2025 · 3 comments · Fixed by #2114 or #2116
Closed
2 tasks done

'xarray.core' has no attribute 'ops' in xarray 2025.03.0 #2113

jensdebruijn opened this issue Mar 20, 2025 · 3 comments · Fixed by #2114 or #2116
Labels
bug Something isn't working

Comments

@jensdebruijn
Copy link
Contributor

Setup Information

  • Xclim version: 0.55.1
  • Python version: python 3.13.2
  • Operating System: linux

Description

When running standardized_precipitation_evapotranspiration_index xclim runs into the error

File ".../.venv/lib/python3.13/site-packages/xclim/indices/generic.py", line 282, in get_op
return xr.core.ops.get_op(binary_op) # noqa
^^^^^^^^^^^
AttributeError: module 'xarray.core' has no attribute 'ops'

The error does not occur with the previous version of xarray 2025.01.2

I believe xr.computation.ops.get_op should become xr.core.ops.get_op. My suggested fix would be:

    if xr.__version__ <= "2025.1.2":
        return xr.core.ops.get_op(binary_op)
    else:
        return xr.computation.ops.get_op(binary_op)  # noqa

Steps To Reproduce

import xarray as xr
import xclim.indices as xci

wb = xr.DataArray(
    data=range(100),
    coords={"time": xr.cftime_range("2000-01-01", periods=100, freq="M")},
    dims=["time"],
    attrs={"units": "kg m-2 s-1"},
)

xci.standardized_precipitation_evapotranspiration_index(wb=wb)

Additional context

No response

Contribution

  • I would be willing/able to open a Pull Request to address this bug.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jensdebruijn jensdebruijn added the bug Something isn't working label Mar 20, 2025
@aulemahal
Copy link
Collaborator

Thanks for the issue @jensdebruijn ! This should have been detected by the upstream CI... I just realized it's been failing (for another reason) for the last week but the automatic issue maker seems not to have been triggered.

If we can solve this without using "private" modules from xarray, it would be better I guess.

@coxipi
Copy link
Contributor

coxipi commented Mar 20, 2025

Hmm, weird. This error was triggerred in the current PR #2112 though

@jensdebruijn
Copy link
Contributor Author

@aulemahal I made a suggestion to solve this without the private modules, see: #2114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants