History

use a copy for the median use a copy for the median

Paul Brossier committed 20 years ago

Commit 0484dc11 parent dcc8d901 file · +6 −3Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/aubio/median.py+6−3
@@ -27,11 +27,14 @@ inspired from http://www.ics.uci.edu/~eppstein/161/python/peters-selection.py · 26 unmodified lines
2727 """
2828
2929 def short_find(a, rank):
30− a.sort()
31− return a[rank - 1]
30+ """ find the rank-th value in sorted a """
31+ # copy to b before sorting
32+ b = a[:]
33+ b.sort()
34+ return b[rank - 1]
3235
33−# Find the rank'th-smallest value in a, in worst-case linear time.
3436 def percental(a, rank):
37+ """ Find the rank'th-smallest value in a, in worst-case linear time. """
3538 n = len(a)
3639 assert 1 <= rank <= n
3740 if n <= 7:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t