diff options
| author | Sebastian Berg <sebastianb@nvidia.com> | 2022-12-06 09:55:38 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-06 09:55:38 +0100 |
| commit | 297c66131f2a32ebb7dfb0aeb9d88d917a791430 (patch) | |
| tree | 99d543dfd704cc6f62d7f8bd9217d82711efa2f6 /numpy/lib/nanfunctions.py | |
| parent | e877ba95bb3e22238353df0d654ef4d425c42f42 (diff) | |
| parent | 91432a36a3611c2374ea9e2d45592f0ac5e71adb (diff) | |
| download | numpy-297c66131f2a32ebb7dfb0aeb9d88d917a791430.tar.gz | |
Merge pull request #22721 from byrdie/bugfix/median-keepdims-out
BUG: `keepdims=True` is ignored if `out` is not `None` in `numpy.median`.
Diffstat (limited to 'numpy/lib/nanfunctions.py')
| -rw-r--r-- | numpy/lib/nanfunctions.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/numpy/lib/nanfunctions.py b/numpy/lib/nanfunctions.py index 3814c0727..ae2dfa165 100644 --- a/numpy/lib/nanfunctions.py +++ b/numpy/lib/nanfunctions.py @@ -1214,12 +1214,9 @@ def nanmedian(a, axis=None, out=None, overwrite_input=False, keepdims=np._NoValu if a.size == 0: return np.nanmean(a, axis, out=out, keepdims=keepdims) - r, k = function_base._ureduce(a, func=_nanmedian, axis=axis, out=out, + return function_base._ureduce(a, func=_nanmedian, keepdims=keepdims, + axis=axis, out=out, overwrite_input=overwrite_input) - if keepdims and keepdims is not np._NoValue: - return r.reshape(k) - else: - return r def _nanpercentile_dispatcher( @@ -1556,17 +1553,14 @@ def _nanquantile_unchecked( # so deal them upfront if a.size == 0: return np.nanmean(a, axis, out=out, keepdims=keepdims) - r, k = function_base._ureduce(a, + return function_base._ureduce(a, func=_nanquantile_ureduce_func, q=q, + keepdims=keepdims, axis=axis, out=out, overwrite_input=overwrite_input, method=method) - if keepdims and keepdims is not np._NoValue: - return r.reshape(q.shape + k) - else: - return r def _nanquantile_ureduce_func(a, q, axis=None, out=None, overwrite_input=False, |
