-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Code Sample, a copy-pastable example if possible
In [1]: import numpy as np
...: import xarray as xr
...:
...: da = xr.DataArray(np.random.randn(1000, 100), dims=['x', 'y'],
...: coords={'x': np.arange(1000)})
...:
In [2]: %%timeit
...: da.rolling(x=10).reduce(np.sum)
...:
2.04 s ± 8.25 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)Problem description
In DataArray.rolling, we index by .isel method for every window, constructing huge number of xr.DataArray instances. This is very inefficient.
Of course, we can use bottleneck methods if available, but this provides only a limited functions.
(This also limits possible extensions of rolling, such as ND-rolling (#819), window type (#1142), strides (#819).)
I am wondering if we could skip any sanity checks in our DataArray.isel -> Variable.isel path in indexing.
Or can we directly construct a single large DataArray instead of a lot of small DataArrays?
jhamman
Metadata
Metadata
Assignees
Labels
No labels