-
Notifications
You must be signed in to change notification settings - Fork 298
Closed
Description
🐛 Bug Report
According to the docstring of iris.util.rolling_window
it maintains laziness when called, but actually passing in a Dask array leads to a crash.
How To Reproduce
Steps to reproduce the behaviour:
In [1]: import dask.array as da
In [2]: from iris.util import rolling_window
In [3]: x = da.arange(10).reshape((2, 5))
In [4]: rolling_window(x, 3).compute()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[4], line 1
----> 1 rolling_window(x, 3)
File ~/src/scitools/iris/lib/iris/util.py:337, in rolling_window(a, window, step, axis)
334 num_windows = (a.shape[axis] - window + step) // step
335 shape = a.shape[:axis] + (num_windows, window) + a.shape[axis + 1 :]
336 strides = (
--> 337 a.strides[:axis]
338 + (step * a.strides[axis], a.strides[axis])
339 + a.strides[axis + 1 :]
340 )
341 rw = np.lib.stride_tricks.as_strided(a, shape=shape, strides=strides)
342 if ma.isMaskedArray(a):
AttributeError: 'Array' object has no attribute 'strides'
Expected behaviour
Instead of a crash, I would expect an output array
In [1]: import dask.array as da
In [2]: from iris.util import rolling_window
In [3]: x = da.arange(10).reshape((2, 5))
In [4]: rolling_window(x, 3).compute()
Out[4]:
array([[[0, 1, 2],
[1, 2, 3],
[2, 3, 4]],
[[5, 6, 7],
[6, 7, 8],
[7, 8, 9]]])
Environment
- OS & Version: Ubuntu 23.10
- Iris Version: 3.8.0.dev125
bjlittle
Metadata
Metadata
Assignees
Type
Projects
Status
✅ Done