From e8706aecdcfe3910861e7e2144919be6d0bcc66f Mon Sep 17 00:00:00 2001 From: fujiisoup Date: Thu, 27 Sep 2018 17:50:44 +0200 Subject: [PATCH 1/2] restore ddof support in std --- xarray/core/nanops.py | 4 ++-- xarray/tests/test_duck_array_ops.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xarray/core/nanops.py b/xarray/core/nanops.py index 2309ed9619d..9549c8e77b9 100644 --- a/xarray/core/nanops.py +++ b/xarray/core/nanops.py @@ -184,9 +184,9 @@ def nanvar(a, axis=None, dtype=None, out=None, ddof=0): a, axis=axis, dtype=dtype, ddof=ddof) -def nanstd(a, axis=None, dtype=None, out=None): +def nanstd(a, axis=None, dtype=None, out=None, ddof=0): return _dask_or_eager_func('nanstd', eager_module=nputils)( - a, axis=axis, dtype=dtype) + a, axis=axis, dtype=dtype, ddof=ddof) def nanprod(a, axis=None, dtype=None, out=None, min_count=None): diff --git a/xarray/tests/test_duck_array_ops.py b/xarray/tests/test_duck_array_ops.py index b9712f60290..aab5d305a82 100644 --- a/xarray/tests/test_duck_array_ops.py +++ b/xarray/tests/test_duck_array_ops.py @@ -309,7 +309,7 @@ def test_reduce(dim_num, dtype, dask, func, skipna, aggdim): assert_allclose(actual, expected, rtol=rtol) # make sure the compatiblility with pandas' results. - if func == 'var': + if func in ['var', 'std']: expected = series_reduce(da, func, skipna=skipna, dim=aggdim, ddof=0) assert_allclose(actual, expected, rtol=rtol) From a50d8ac2f39ed996b25793c50946ccef90ce5974 Mon Sep 17 00:00:00 2001 From: fujiisoup Date: Fri, 28 Sep 2018 08:14:47 +0200 Subject: [PATCH 2/2] whats new --- doc/whats-new.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 67d0d548ec5..adaec7af7a7 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -39,6 +39,9 @@ Enhancements Bug fixes ~~~~~~~~~ +- ``xarray.DataArray.std()`` now correctly accepts ``ddof`` keyword argument. + (:issue:`2240`) + By `Keisuke Fujii `_. .. _whats-new.0.10.9: