From 0484dc1819cdf9bf8ce7c0916943c36171c35de9 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Wed, 1 Mar 2006 03:15:54 +0000 Subject: [PATCH] use a copy for the median use a copy for the median --- python/aubio/median.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/aubio/median.py b/python/aubio/median.py index e0f9eea0..b039725b 100644 --- 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: -- 2.26.2