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

Function _nanmedian_small

numpy/lib/nanfunctions.py:1101–1118  ·  view source on GitHub ↗

sort + indexing median, faster for small medians along multiple dimensions due to the high overhead of apply_along_axis see nanmedian for parameter usage

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

Source from the content-addressed store, hash-verified

1099
1100
1101def _nanmedian_small(a, axis=None, out=None, overwrite_input=False):
1102 """
1103 sort + indexing median, faster for small medians along multiple
1104 dimensions due to the high overhead of apply_along_axis
1105
1106 see nanmedian for parameter usage
1107 """
1108 a = np.ma.masked_array(a, np.isnan(a))
1109 m = np.ma.median(a, axis=axis, overwrite_input=overwrite_input)
1110 for i in range(np.count_nonzero(m.mask.ravel())):
1111 warnings.warn("All-NaN slice encountered", RuntimeWarning,
1112 stacklevel=5)
1113
1114 fill_value = np.timedelta64("NaT") if m.dtype.kind == "m" else np.nan
1115 if out is not None:
1116 out[...] = m.filled(fill_value)
1117 return out
1118 return m.filled(fill_value)
1119
1120
1121def _nanmedian_dispatcher(

Callers 1

_nanmedianFunction · 0.85

Calls 3

warnMethod · 0.80
ravelMethod · 0.45
filledMethod · 0.45

Tested by

no test coverage detected