From 7434633ff336917d3ded804aeb0e5695c6bd806a Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Sat, 17 Dec 2016 13:07:34 +0100 Subject: [PATCH] ENH: retune apply_along_axis nanmedian cutoff Old value was erroneously obtained on a sorted array which is a best case for the median of 3 pivoted introsort. --- numpy/lib/nanfunctions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/numpy/lib/nanfunctions.py b/numpy/lib/nanfunctions.py index 812b9bcb3e80..9b9df77c3ab8 100644 --- a/numpy/lib/nanfunctions.py +++ b/numpy/lib/nanfunctions.py @@ -869,7 +869,8 @@ def _nanmedian(a, axis=None, out=None, overwrite_input=False): else: # for small medians use sort + indexing which is still faster than # apply_along_axis - if a.shape[axis] < 1000: + # benchmarked with shuffled (50, 50, x) containing a few NaN + if a.shape[axis] < 600: return _nanmedian_small(a, axis, out, overwrite_input) result = np.apply_along_axis(_nanmedian1d, axis, a, overwrite_input) if out is not None: