summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py18
1 files changed, 1 insertions, 17 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 352512513..172e9a322 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -3982,23 +3982,7 @@ def _median(a, axis=None, out=None, overwrite_input=False):
if np.issubdtype(a.dtype, np.inexact) and sz > 0:
# warn and return nans like mean would
rout = mean(part[indexer], axis=axis, out=out)
- part = np.rollaxis(part, axis, part.ndim)
- n = np.isnan(part[..., -1])
- if rout.ndim == 0:
- if n == True:
- warnings.warn("Invalid value encountered in median",
- RuntimeWarning, stacklevel=3)
- if out is not None:
- out[...] = a.dtype.type(np.nan)
- rout = out
- else:
- rout = a.dtype.type(np.nan)
- elif np.count_nonzero(n.ravel()) > 0:
- warnings.warn("Invalid value encountered in median for" +
- " %d results" % np.count_nonzero(n.ravel()),
- RuntimeWarning, stacklevel=3)
- rout[n] = np.nan
- return rout
+ return np.lib.utils._median_nancheck(part, rout, axis, out)
else:
# if there are no nans
# Use mean in odd and even case to coerce data type