MCPcopy Create free account
hub / github.com/numpy/numpy / _nanmedian

Function _nanmedian

numpy/lib/nanfunctions.py:1075–1098  ·  view source on GitHub ↗

Private function that doesn't support extended axis or keepdims. These methods are extended to this function using _ureduce See nanmedian for parameter usage

(a, axis=None, out=None, overwrite_input=False)

Source from the content-addressed store, hash-verified

1073
1074
1075def _nanmedian(a, axis=None, out=None, overwrite_input=False):
1076 """
1077 Private function that doesn't support extended axis or keepdims.
1078 These methods are extended to this function using _ureduce
1079 See nanmedian for parameter usage
1080
1081 """
1082 if axis is None or a.ndim == 1:
1083 part = a.ravel()
1084 if out is None:
1085 return _nanmedian1d(part, overwrite_input)
1086 else:
1087 out[...] = _nanmedian1d(part, overwrite_input)
1088 return out
1089 else:
1090 # for small medians use sort + indexing which is still faster than
1091 # apply_along_axis
1092 # benchmarked with shuffled (50, 50, x) containing a few NaN
1093 if a.shape[axis] < 600:
1094 return _nanmedian_small(a, axis, out, overwrite_input)
1095 result = np.apply_along_axis(_nanmedian1d, axis, a, overwrite_input)
1096 if out is not None:
1097 out[...] = result
1098 return result
1099
1100
1101def _nanmedian_small(a, axis=None, out=None, overwrite_input=False):

Callers

nothing calls this directly

Calls 3

_nanmedian1dFunction · 0.85
_nanmedian_smallFunction · 0.85
ravelMethod · 0.45

Tested by

no test coverage detected