From e30d80266d476841e51d36432d1640f278a5fa05 Mon Sep 17 00:00:00 2001 From: Joseph Fox-Rabinovitz Date: Wed, 3 Feb 2016 15:48:07 -0500 Subject: BUG: Fixed previous attempt to fix dimension mismatch in nanpercentile nanpercentile was conforming to dimension convention of percentile incorrectly. percentile outputs results for the different percentiles along the first dimension of the output. nanpercentile was moving the reduction axis to the front using swapaxes, which would move the first axis out of place if there were more than two in the array. Added a test with more than two axes to demonstrate and used rollaxis instead of swapaxes to do the interhange. --- numpy/lib/nanfunctions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'numpy/lib/nanfunctions.py') diff --git a/numpy/lib/nanfunctions.py b/numpy/lib/nanfunctions.py index 6b28b4a35..491a28d22 100644 --- a/numpy/lib/nanfunctions.py +++ b/numpy/lib/nanfunctions.py @@ -979,7 +979,8 @@ def _nanpercentile(a, q, axis=None, out=None, overwrite_input=False, # Move that axis to the beginning to match percentile's # convention. if q.ndim != 0: - result = np.swapaxes(result, 0, axis) + result = np.rollaxis(result, axis) + if out is not None: out[...] = result return result -- cgit v1.2.1