History

python/tests/test_source.py: check the tail of the file is non-zero on non silent test files

Paul Brossier committed 10 years ago

Commit f91737d1 parent 80d00831 file · +14 −5Browse files

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

Unified · Split

python/tests/test_source.py+14−5
@@ -2,9 +2,10 @@ · 1 unmodified line
2 2
3from nose2 import main3from nose2 import main
4from nose2.tools import params4from nose2.tools import params
5from numpy.testing import TestCase5from numpy.testing import TestCase, assert_equal
6from aubio import source6from aubio import source
7from utils import list_all_sounds7from utils import list_all_sounds
8import numpy as np
8 9
9import warnings10import warnings
10warnings.filterwarnings('ignore', category=UserWarning, append=True)11warnings.filterwarnings('ignore', category=UserWarning, append=True)
@@ -51,9 +52,13 @@ class aubio_source_read_test_case(aubio_source_test_case_base): · 40 unmodified lines
51 def read_from_source(self, f):52 def read_from_source(self, f):
52 total_frames = 053 total_frames = 0
53 while True:54 while True:
54 _ , read = f()55 samples , read = f()
55 total_frames += read56 total_frames += read
56 if read < f.hop_size: break57 if read < f.hop_size:
58 assert_equal(samples[read:], 0)
59 if 'silence' not in f.uri:
60 self.assertEquals(np.count_nonzero(samples[:read]), read)
61 break
57 #result_str = "read {:.2f}s ({:d} frames in {:d} blocks at {:d}Hz) from {:s}"62 #result_str = "read {:.2f}s ({:d} frames in {:d} blocks at {:d}Hz) from {:s}"
58 #result_params = total_frames / float(f.samplerate), total_frames, total_frames//f.hop_size, f.samplerate, f.uri63 #result_params = total_frames / float(f.samplerate), total_frames, total_frames//f.hop_size, f.samplerate, f.uri
59 #print (result_str.format(*result_params))64 #print (result_str.format(*result_params))
@@ -149,9 +154,13 @@ class aubio_source_readmulti_test_case(aubio_source_read_test_case): · 89 unmodified lines
149 def read_from_source(self, f):154 def read_from_source(self, f):
150 total_frames = 0155 total_frames = 0
151 while True:156 while True:
152 _, read = f.do_multi()157 samples, read = f.do_multi()
153 total_frames += read158 total_frames += read
154 if read < f.hop_size: break159 if read < f.hop_size:
160 assert_equal(samples[:,read:], 0)
161 if 'silence' not in f.uri:
162 self.assertEquals(np.count_nonzero(samples[:,:read]), read)
163 break
155 #result_str = "read {:.2f}s ({:d} frames in {:d} channels and {:d} blocks at {:d}Hz) from {:s}"164 #result_str = "read {:.2f}s ({:d} frames in {:d} channels and {:d} blocks at {:d}Hz) from {:s}"
156 #result_params = total_frames / float(f.samplerate), total_frames, f.channels, int(total_frames/f.hop_size), f.samplerate, f.uri165 #result_params = total_frames / float(f.samplerate), total_frames, f.channels, int(total_frames/f.hop_size), f.samplerate, f.uri
157 #print (result_str.format(*result_params))166 #print (result_str.format(*result_params))

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