summaryrefslogtreecommitdiff
path: root/numpy/lib/nanfunctions.py
diff options
context:
space:
mode:
authorJoseph Fox-Rabinovitz <joseph.r.fox-rabinovitz@nasa.gov>2016-02-03 15:48:07 -0500
committerJoseph Fox-Rabinovitz <joseph.r.fox-rabinovitz@nasa.gov>2016-02-05 14:34:55 -0500
commite30d80266d476841e51d36432d1640f278a5fa05 (patch)
treeb068c5b07f1c0a53932b61cf0e5007a1218f7ad7 /numpy/lib/nanfunctions.py
parent12ec338c23f3db1e155661fdbf098a546e48dc1e (diff)
downloadnumpy-e30d80266d476841e51d36432d1640f278a5fa05.tar.gz
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.
Diffstat (limited to 'numpy/lib/nanfunctions.py')
-rw-r--r--numpy/lib/nanfunctions.py3
1 files changed, 2 insertions, 1 deletions
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