From 098daf3020e817d03a17a81963ad3cf831fbb48c Mon Sep 17 00:00:00 2001 From: keisukefujii Date: Mon, 6 May 2019 23:20:12 +0200 Subject: [PATCH 1/2] Fix: 2940 --- doc/whats-new.rst | 11 +++++++---- xarray/core/rolling.py | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index b88d10ffc23..d7ce50ecc00 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -27,10 +27,13 @@ Enhancements - Character arrays' character dimension name decoding and encoding handled by ``var.encoding['char_dim_name']`` (:issue:`2895`) By `James McCreight `_. - + Bug fixes ~~~~~~~~~ +- a bug fix in rolling with dask and bottleneck + (:issue:`2940`) + By `Keisuke Fujii `_. - indexing with an empty list creates an object with zero-length axis (:issue:`2882`) By `Mayeul d'Avezac `_. - Return correct count for scalar datetime64 arrays (:issue:`2770`) @@ -147,9 +150,9 @@ Other enhancements By `Keisuke Fujii `_. - Added :py:meth:`~xarray.Dataset.drop_dims` (:issue:`1949`). By `Kevin Squire `_. -- ``xr.open_zarr`` now accepts manually specified chunks with the ``chunks=`` - parameter. ``auto_chunk=True`` is equivalent to ``chunks='auto'`` for - backwards compatibility. The ``overwrite_encoded_chunks`` parameter is +- ``xr.open_zarr`` now accepts manually specified chunks with the ``chunks=`` + parameter. ``auto_chunk=True`` is equivalent to ``chunks='auto'`` for + backwards compatibility. The ``overwrite_encoded_chunks`` parameter is added to remove the original zarr chunk encoding. By `Lily Wang `_. diff --git a/xarray/core/rolling.py b/xarray/core/rolling.py index 8a974e2da72..94369bea906 100644 --- a/xarray/core/rolling.py +++ b/xarray/core/rolling.py @@ -275,7 +275,7 @@ def wrapped_func(self, **kwargs): if isinstance(padded.data, dask_array_type): # Workaround to make the padded chunk size is larger than # self.window-1 - shift = - (self.window + 1) // 2 + shift = - (self.window - 1) offset = (self.window - 1) // 2 valid = (slice(None), ) * axis + ( slice(offset, offset + self.obj.shape[axis]), ) @@ -285,7 +285,7 @@ def wrapped_func(self, **kwargs): padded = padded.pad_with_fill_value({self.dim: (0, -shift)}) if isinstance(padded.data, dask_array_type): - values = dask_rolling_wrapper(func, padded, + values = dask_rolling_wrapper(func, padded.data, window=self.window, min_count=min_count, axis=axis) From ca96cc3b709ef043a7fa54030c6ddf26da8b4089 Mon Sep 17 00:00:00 2001 From: keisukefujii Date: Mon, 6 May 2019 23:38:41 +0200 Subject: [PATCH 2/2] Remove skipping test for this bug. --- xarray/tests/test_dataarray.py | 1 - 1 file changed, 1 deletion(-) diff --git a/xarray/tests/test_dataarray.py b/xarray/tests/test_dataarray.py index ab6a5eb3626..65ee0c0d69e 100644 --- a/xarray/tests/test_dataarray.py +++ b/xarray/tests/test_dataarray.py @@ -3618,7 +3618,6 @@ def test_rolling_wrapped_bottleneck(da, name, center, min_periods): @pytest.mark.parametrize('center', (True, False, None)) @pytest.mark.parametrize('min_periods', (1, None)) @pytest.mark.parametrize('window', (7, 8)) -@pytest.mark.xfail(reason='https://github.com/pydata/xarray/issues/2940') def test_rolling_wrapped_dask(da_dask, name, center, min_periods, window): pytest.importorskip('dask.array') # dask version