projects
/
aubio.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
dcc8d90
)
use a copy for the median
author
Paul Brossier
<piem@altern.org>
Wed, 1 Mar 2006 03:15:54 +0000
(
03:15
+0000)
committer
Paul Brossier
<piem@altern.org>
Wed, 1 Mar 2006 03:15:54 +0000
(
03:15
+0000)
use a copy for the median
python/aubio/median.py
patch
|
blob
|
history
diff --git
a/python/aubio/median.py
b/python/aubio/median.py
index e0f9eea061cecf69a1802df5ea1777f56b60890b..b039725beb725e7dd1104eb056429caa248f8f6f 100644
(file)
--- a/
python/aubio/median.py
+++ b/
python/aubio/median.py
@@
-27,11
+27,14
@@
inspired from http://www.ics.uci.edu/~eppstein/161/python/peters-selection.py
"""
def short_find(a, rank):
- a.sort()
- return a[rank - 1]
+ """ find the rank-th value in sorted a """
+ # copy to b before sorting
+ b = a[:]
+ b.sort()
+ return b[rank - 1]
-# Find the rank'th-smallest value in a, in worst-case linear time.
def percental(a, rank):
+ """ Find the rank'th-smallest value in a, in worst-case linear time. """
n = len(a)
assert 1 <= rank <= n
if n <= 7: