diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2006-09-26 17:01:15 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2006-09-26 17:01:15 +0000 |
commit | 61fbe0e45c5e22054190b6973d7f23c1f95434e6 (patch) | |
tree | 253cdd3a21599c8b870ff634c55b61e76e8c9b01 /numpy/lib/function_base.py | |
parent | aaaa7aff433adc022a21599b60cfb02c0c168b5d (diff) | |
download | numpy-61fbe0e45c5e22054190b6973d7f23c1f95434e6.tar.gz |
Sort only once in median.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 5 |
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): |