Skip to content

Commit 0dbc9ad

Browse files
committed
MAINT: remove unused argument in private function
1 parent 6ba4872 commit 0dbc9ad

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

numpy/lib/function_base.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3714,16 +3714,15 @@ def _median(a, axis=None, out=None, overwrite_input=False):
37143714
indexer[axis] = slice(index-1, index+1)
37153715
indexer = tuple(indexer)
37163716

3717+
# Use mean in both odd and even case to coerce data type,
3718+
# using out array if needed.
3719+
rout = mean(part[indexer], axis=axis, out=out)
37173720
# Check if the array contains any nan's
37183721
if np.issubdtype(a.dtype, np.inexact) and sz > 0:
3719-
# warn and return nans like mean would
3720-
rout = mean(part[indexer], axis=axis, out=out)
3721-
return np.lib.utils._median_nancheck(part, rout, axis, out)
3722-
else:
3723-
# if there are no nans
3724-
# Use mean in odd and even case to coerce data type
3725-
# and check, use out array.
3726-
return mean(part[indexer], axis=axis, out=out)
3722+
# If nans are possible, warn and replace by nans like mean would.
3723+
rout = np.lib.utils._median_nancheck(part, rout, axis)
3724+
3725+
return rout
37273726

37283727

37293728
def _percentile_dispatcher(a, q, axis=None, out=None, overwrite_input=None,

numpy/lib/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ def safe_eval(source):
10021002
return ast.literal_eval(source)
10031003

10041004

1005-
def _median_nancheck(data, result, axis, out):
1005+
def _median_nancheck(data, result, axis):
10061006
"""
10071007
Utility function to check median result from data for NaN values at the end
10081008
and return NaN in that case. Input result can also be a MaskedArray.
@@ -1012,16 +1012,16 @@ def _median_nancheck(data, result, axis, out):
10121012
data : array
10131013
Input data to median function
10141014
result : Array or MaskedArray
1015-
Result of median function
1015+
Result of median function.
10161016
axis : int
10171017
Axis along which the median was computed.
1018-
out : ndarray, optional
1019-
Output array in which to place the result.
10201018
10211019
Returns
10221020
-------
1023-
median : scalar or ndarray
1024-
Median or NaN in axes which contained NaN in the input.
1021+
result : scalar or ndarray
1022+
Median or NaN in axes which contained NaN in the input. If the input
1023+
was an array, NaN will be inserted in-place. If a scalar, either the
1024+
input itself or a scalar NaN.
10251025
"""
10261026
if data.size == 0:
10271027
return result

numpy/ma/extras.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ def _median(a, axis=None, out=None, overwrite_input=False):
750750
s = mid.sum(out=out)
751751
if not odd:
752752
s = np.true_divide(s, 2., casting='safe', out=out)
753-
s = np.lib.utils._median_nancheck(asorted, s, axis, out)
753+
s = np.lib.utils._median_nancheck(asorted, s, axis)
754754
else:
755755
s = mid.mean(out=out)
756756

@@ -790,7 +790,7 @@ def replace_masked(s):
790790
s = np.ma.sum(low_high, axis=axis, out=out)
791791
np.true_divide(s.data, 2., casting='unsafe', out=s.data)
792792

793-
s = np.lib.utils._median_nancheck(asorted, s, axis, out)
793+
s = np.lib.utils._median_nancheck(asorted, s, axis)
794794
else:
795795
s = np.ma.mean(low_high, axis=axis, out=out)
796796

0 commit comments

Comments
 (0)