History

python/demos/demo_bpm_extract.py: add exception type, avoid {} as default argument value

Paul Brossier committed 10 years ago

Commit 494df021 parent 67e16c21 file · +4 −2Browse files

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

Unified · Split

python/demos/demo_bpm_extract.py+4−2
@@ -3,16 +3,18 @@ · 2 unmodified lines
33 from aubio import source, tempo
44 from numpy import median, diff
55
6−def get_file_bpm(path, params = {}):
6+def get_file_bpm(path, params = None):
77 """ Calculate the beats per minute (bpm) of a given file.
88 path: path to the file
99 param: dictionary of parameters
1010 """
11+ if params == None:
12+ params = {}
1113 try:
1214 win_s = params['win_s']
1315 samplerate = params['samplerate']
1416 hop_s = params['hop_s']
15− except:
17+ except KeyError:
1618 """
1719 # super fast
1820 samplerate, win_s, hop_s = 4000, 128, 64

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