History

tests/test_pitch.py: add more tests

Paul Brossier committed 11 years ago

Commit b74513d1 parent 048dd6c1 file · +27 −4Browse files

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

Unified · Split

python/tests/test_pitch.py+27−4
@@ -67,13 +67,35 @@ class aubio_pitch_Sinusoid(TestCase): · 66 unmodified lines
67 pitches = pitches[2:]67 pitches = pitches[2:]
68 errors = errors[2:]68 errors = errors[2:]
69 # check that the mean of all relative errors is less than 10%69 # check that the mean of all relative errors is less than 10%
70 assert abs (mean(errors) ) < 0.1, pitches70 #assert abs (mean(errors) ) < 0.1, pitches
71 assert abs (mean(errors) ) < 0.1, "error is bigger than 0.1 (%f)" % mean(errors)71 assert abs (median(errors) ) < 0.06, "median of relative errors is bigger than 0.06 (%f)\n found %s\n errors %s" % (mean(errors), pitches, errors)
72 #print 'len(pitches), cut:', len(pitches), cut72 #print 'len(pitches), cut:', len(pitches), cut
73 #print 'mean errors: ', mean(errors), 'mean pitches: ', mean(pitches)73 #print 'median errors: ', median(errors), 'median pitches: ', median(pitches)
74 74
75pitch_algorithms = [ "default", "yinfft", "yin", "schmitt", "mcomb", "fcomb" , "specacf" ]75pitch_algorithms = [ "default", "yinfft", "yin", "schmitt", "mcomb", "fcomb" , "specacf" ]
76pitch_algorithms = [ "default", "yinfft", "yin", "schmitt", "mcomb", "fcomb" ]
77
78#freqs = [ 27.5, 55., 110., 220., 440., 880., 1760., 3520. ]
79freqs = [ 110., 220., 440., 880., 1760., 3520. ]
80signal_modes = []
81for freq in freqs:
82 signal_modes += [
83 ( 4096, 2048, 44100, freq ),
84 ( 2048, 512, 44100, freq ),
85 ( 2048, 1024, 44100, freq ),
86 ( 2048, 1024, 32000, freq ),
87 ]
88
89freqs = [ ] #55., 110., 220., 440., 880., 1760., 3520. ]
90for freq in freqs:
91 signal_modes += [
92 ( 2048, 1024, 22050, freq ),
93 ( 1024, 256, 16000, freq ),
94 ( 1024, 256, 8000, freq ),
95 ( 1024, 512+256, 8000, freq ),
96 ]
76 97
98"""
77signal_modes = [99signal_modes = [
78 ( 4096, 512, 44100, 2.*882. ),100 ( 4096, 512, 44100, 2.*882. ),
79 ( 4096, 512, 44100, 882. ),101 ( 4096, 512, 44100, 882. ),
@@ -87,6 +109,7 @@ signal_modes = [ · 7 unmodified lines
87 ( 1024, 256, 8000, 440. ),109 ( 1024, 256, 8000, 440. ),
88 ( 1024, 512+256, 8000, 440. ),110 ( 1024, 512+256, 8000, 440. ),
89 ]111 ]
112"""
90 113
91def create_test (algo, mode):114def create_test (algo, mode):
92 def do_test_pitch(self):115 def do_test_pitch(self):
@@ -96,7 +119,7 @@ def create_test (algo, mode): · 3 unmodified lines
96for algo in pitch_algorithms:119for algo in pitch_algorithms:
97 for mode in signal_modes:120 for mode in signal_modes:
98 test_method = create_test (algo, mode)121 test_method = create_test (algo, mode)
99 test_method.__name__ = 'test_pitch_%s_%d_%d_%dHz_sin_%.2f' % ( algo,122 test_method.__name__ = 'test_pitch_%s_%d_%d_%dHz_sin_%.0f' % ( algo,
100 mode[0], mode[1], mode[2], mode[3] )123 mode[0], mode[1], mode[2], mode[3] )
101 setattr (aubio_pitch_Sinusoid, test_method.__name__, test_method)124 setattr (aubio_pitch_Sinusoid, test_method.__name__, test_method)
102 125

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