Skip to content

Commit

Permalink
Fix rolling.constuct() example (#2967)
Browse files Browse the repository at this point in the history
* The example was using the wrong name for the function (to_datarray),
  and used the wrong dimension for the window
  • Loading branch information
kmsquire authored and fujiisoup committed May 16, 2019
1 parent bd78b7f commit 6658108
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions xarray/core/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ def construct(self, window_dim, stride=1, fill_value=dtypes.NA):
--------
>>> da = DataArray(np.arange(8).reshape(2, 4), dims=('a', 'b'))
>>>
>>> rolling = da.rolling(a=3)
>>> rolling.to_datarray('window_dim')
>>> rolling = da.rolling(b=3)
>>> rolling.construct('window_dim')
<xarray.DataArray (a: 2, b: 4, window_dim: 3)>
array([[[np.nan, np.nan, 0], [np.nan, 0, 1], [0, 1, 2], [1, 2, 3]],
[[np.nan, np.nan, 4], [np.nan, 4, 5], [4, 5, 6], [5, 6, 7]]])
Dimensions without coordinates: a, b, window_dim
>>>
>>> rolling = da.rolling(a=3, center=True)
>>> rolling.to_datarray('window_dim')
>>> rolling = da.rolling(b=3, center=True)
>>> rolling.construct('window_dim')
<xarray.DataArray (a: 2, b: 4, window_dim: 3)>
array([[[np.nan, 0, 1], [0, 1, 2], [1, 2, 3], [2, 3, np.nan]],
[[np.nan, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, np.nan]]])
Expand Down

0 comments on commit 6658108

Please sign in to comment.