summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authorStefan van der Walt <stefan@sun.ac.za>2006-09-26 17:01:15 +0000
committerStefan van der Walt <stefan@sun.ac.za>2006-09-26 17:01:15 +0000
commit61fbe0e45c5e22054190b6973d7f23c1f95434e6 (patch)
tree253cdd3a21599c8b870ff634c55b61e76e8c9b01 /numpy/lib/function_base.py
parentaaaa7aff433adc022a21599b60cfb02c0c168b5d (diff)
downloadnumpy-61fbe0e45c5e22054190b6973d7f23c1f95434e6.tar.gz
Sort only once in median.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index f13736f2a..4478a332f 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -1046,11 +1046,10 @@ def median(m):
"""median(m) returns a median of m along the first dimension of m.
"""
sorted = msort(m)
+ index = int(sorted.shape[0]/2)
if sorted.shape[0] % 2 == 1:
- return sorted[int(sorted.shape[0]/2)]
+ return sorted[index]
else:
- sorted = msort(m)
- index = sorted.shape[0]/2
return (sorted[index-1]+sorted[index])/2.0
def trapz(y, x=None, dx=1.0, axis=-1):