diff options
author | Mateusz Sokół <8431159+mtsokol@users.noreply.github.com> | 2021-03-11 23:59:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-11 16:59:16 -0600 |
commit | c5de5b5c2cf048e1556f31dfcfa031c8f624b98e (patch) | |
tree | 985787b74ce260686a25d80f16e971ddbd3479e7 /numpy/core/_methods.py | |
parent | e8d20b5731e965127c6157a1f34f6970a8ae550c (diff) | |
download | numpy-c5de5b5c2cf048e1556f31dfcfa031c8f624b98e.tar.gz |
BUG: Fixed ``where`` keyword for ``np.mean`` & ``np.var`` methods (gh-18560)
* Fixed keyword bug
* Added test case
* Reverted to original notation
* Added tests for var and std
Closes gh-18552
Diffstat (limited to 'numpy/core/_methods.py')
-rw-r--r-- | numpy/core/_methods.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/numpy/core/_methods.py b/numpy/core/_methods.py index 1867ba68c..09147fe5b 100644 --- a/numpy/core/_methods.py +++ b/numpy/core/_methods.py @@ -165,7 +165,7 @@ def _mean(a, axis=None, dtype=None, out=None, keepdims=False, *, where=True): is_float16_result = False rcount = _count_reduce_items(arr, axis, keepdims=keepdims, where=where) - if rcount == 0 if where is True else umr_any(rcount == 0): + if rcount == 0 if where is True else umr_any(rcount == 0, axis=None): warnings.warn("Mean of empty slice.", RuntimeWarning, stacklevel=2) # Cast bool, unsigned int, and int to float64 by default @@ -198,7 +198,7 @@ def _var(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, rcount = _count_reduce_items(arr, axis, keepdims=keepdims, where=where) # Make this warning show up on top. - if ddof >= rcount if where is True else umr_any(ddof >= rcount): + if ddof >= rcount if where is True else umr_any(ddof >= rcount, axis=None): warnings.warn("Degrees of freedom <= 0 for slice", RuntimeWarning, stacklevel=2) |