Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore ddof support in std #2447

Merged
merged 2 commits into from
Sep 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Enhancements
Bug fixes
~~~~~~~~~

- ``xarray.DataArray.std()`` now correctly accepts ``ddof`` keyword argument.
(:issue:`2240`)
By `Keisuke Fujii <https://github.com/fujiisoup>`_.

.. _whats-new.0.10.9:

Expand Down
4 changes: 2 additions & 2 deletions xarray/core/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
Thanks for fixing.
Is there any reason why not all remaining keywords are passed on (as **kwds or something)?
I think that would help to maintain numpy compatibility.
Cheers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds a good idea.
I just did not notice that there are significant keywords other than axis and out.
Your contribution is welcome ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reply.
You are probably right, although the numpy functions also accept a keepdims keyword, don't know how xarray deals with that. I was more thinking about future proofness in the case the numpy or dask people decide to support more keywords. But that could be discussed then if that really happens.
Cheers.



def nanprod(a, axis=None, dtype=None, out=None, min_count=None):
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_duck_array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down