Skip to content

DataArray.rolling fails with chunk size of 1 or 2 (reemergence of issue #9862) #10115

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

Open
4 of 5 tasks
pittwolfe opened this issue Mar 11, 2025 · 3 comments
Open
4 of 5 tasks
Labels
bug needs triage Issue that has not been reviewed by xarray team member

Comments

@pittwolfe
Copy link

What happened?

The problem is exactly as written in closed issue #9862, but I'm using:

  • xarray: 2025.1.2
  • dask: 2025.2.0

Since everything is the same (including traceback and behavior when pasted into console or binder), please refer to original issue for complete description.

I didn't click "new issue" since it's an old issue that was closed, but is not fixed.

What did you expect to happen?

We would expect the rolling mean to calculate correctly.

Minimal Complete Verifiable Example

import dask.array as da
import xarray as xr
import numpy as np

# Dimensions and sizes
nx, ny, nt = 100, 200, 50  # size of x, y, and time dimensions
x = np.linspace(0, 10, nx)  # x-coordinates
y = np.linspace(0, 20, ny)  # y-coordinates
time = np.linspace(0, 1, nt)  # time coordinates

# Generate a random Dask array with lazy computation
data = da.random.random(size=(nx, ny, nt), chunks=(100, 200, 1))

# Create an xarray DataArray with coordinates and attributes
data_array = xr.DataArray(
    data,
    dims=["x", "y", "time"],
    coords={"x": x, "y": y, "time": time},
    name="dummy_data",
    attrs={"units": "arbitrary", "description": "Dummy 3D dataset"}
)

d_rolling = data_array.rolling(time=5).mean()
d_rolling.compute()

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

Traceback (most recent call last):

  Cell In[6], line 24
    d_rolling.compute()

  File /srv/conda/envs/notebook/lib/python3.10/site-packages/xarray/core/dataarray.py:1206 in compute
    return new.load(**kwargs)

  File /srv/conda/envs/notebook/lib/python3.10/site-packages/xarray/core/dataarray.py:1174 in load
    ds = self._to_temp_dataset().load(**kwargs)

  File /srv/conda/envs/notebook/lib/python3.10/site-packages/xarray/core/dataset.py:900 in load
    evaluated_data: tuple[np.ndarray[Any, Any], ...] = chunkmanager.compute(

  File /srv/conda/envs/notebook/lib/python3.10/site-packages/xarray/namedarray/daskmanager.py:85 in compute
    return compute(*data, **kwargs)  # type: ignore[no-untyped-call, no-any-return]

  File /srv/conda/envs/notebook/lib/python3.10/site-packages/dask/base.py:662 in compute
    results = schedule(dsk, keys, **kwargs)

  File /srv/conda/envs/notebook/lib/python3.10/site-packages/dask/_task_spec.py:740 in __call__
    return self.func(*new_argspec, **kwargs)

ValueError: Moving window (=5) must between 1 and 4, inclusive

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS ------------------ commit: None python: 3.10.16 | packaged by conda-forge | (main, Dec 5 2024, 14:16:10) [GCC 13.3.0] python-bits: 64 OS: Linux OS-release: 6.8.0-52-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: en_US.UTF-8 LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.14.3 libnetcdf: 4.9.2

xarray: 2025.1.2
pandas: 2.2.3
numpy: 2.1.3
scipy: 1.15.2
netCDF4: 1.7.2
pydap: 3.5.3
h5netcdf: 1.5.0
h5py: 3.13.0
zarr: 2.18.3
cftime: 1.6.4
nc_time_axis: 1.4.1
iris: 3.11.0
bottleneck: 1.4.2
dask: 2025.2.0
distributed: 2025.2.0
matplotlib: 3.10.1
cartopy: 0.24.0
seaborn: 0.13.2
numbagg: 0.9.0
fsspec: 2025.2.0
cupy: None
pint: 0.24.4
sparse: 0.15.5
flox: None
numpy_groupies: None
setuptools: 75.8.0
pip: 25.0
conda: None
pytest: None
mypy: None
IPython: 8.32.0
sphinx: None

@pittwolfe pittwolfe added bug needs triage Issue that has not been reviewed by xarray team member labels Mar 11, 2025
Copy link

welcome bot commented Mar 11, 2025

Thanks for opening your first issue here at xarray! Be sure to follow the issue template!
If you have an idea for a solution, we would really welcome a Pull Request with proposed changes.
See the Contributing Guide for more.
It may take us a while to respond here, but we really value your contribution. Contributors like you help make xarray better.
Thank you!

@paololucchino
Copy link

As mentioned in the thread of the original #9862, the issue is with bottleneck. Hope there is a fix that can be applied! Thanks!

@paololucchino
Copy link

Hi xarray team! Any feedback on this issue? Thanks!

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

2 participants