diff options
Diffstat (limited to 'numpy/lib/nanfunctions.py')
-rw-r--r-- | numpy/lib/nanfunctions.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/numpy/lib/nanfunctions.py b/numpy/lib/nanfunctions.py index 1e342b932..c95c845f3 100644 --- a/numpy/lib/nanfunctions.py +++ b/numpy/lib/nanfunctions.py @@ -837,7 +837,7 @@ def _nanmedian1d(arr1d, overwrite_input=False): See nanmedian for parameter usage """ c = np.isnan(arr1d) - s = np.where(c)[0] + s = np.nonzero(c)[0] if s.size == arr1d.size: warnings.warn("All-NaN slice encountered", RuntimeWarning, stacklevel=3) return np.nan @@ -1088,7 +1088,7 @@ def nanpercentile(a, q, axis=None, out=None, overwrite_input=False, >>> a[0][1] = np.nan >>> a array([[ 10., nan, 4.], - [ 3., 2., 1.]]) + [ 3., 2., 1.]]) >>> np.percentile(a, 50) nan >>> np.nanpercentile(a, 50) @@ -1123,10 +1123,7 @@ def nanpercentile(a, q, axis=None, out=None, overwrite_input=False, overwrite_input=overwrite_input, interpolation=interpolation) if keepdims and keepdims is not np._NoValue: - if q.ndim == 0: - return r.reshape(k) - else: - return r.reshape([len(q)] + k) + return r.reshape(q.shape + k) else: return r @@ -1164,7 +1161,7 @@ def _nanpercentile1d(arr1d, q, overwrite_input=False, interpolation='linear'): See nanpercentile for parameter usage """ c = np.isnan(arr1d) - s = np.where(c)[0] + s = np.nonzero(c)[0] if s.size == arr1d.size: warnings.warn("All-NaN slice encountered", RuntimeWarning, stacklevel=3) if q.ndim == 0: |