Changeset 0b6d23d for python/tests/test_source.py
- Timestamp:
- May 16, 2016, 5:08:18 AM (8 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- a6f9ebf
- Parents:
- 58a5fb9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_source.py
r58a5fb9 r0b6d23d 1 1 #! /usr/bin/env python 2 2 3 from numpy.testing import TestCase, assert_equal, assert_almost_equal 4 from aubio import fvec, source 5 from numpy import array 3 from nose2 import main 4 from nose2.tools import params 5 from numpy.testing import TestCase 6 from aubio import source 6 7 from utils import list_all_sounds 7 from nose2.tools import params8 8 9 9 list_of_sounds = list_all_sounds('sounds') … … 48 48 total_frames = 0 49 49 while True: 50 vec, read = f()50 _ , read = f() 51 51 total_frames += read 52 52 if read < f.hop_size: break 53 result_str = "read {:.2f}s ({:d} frames in {:d} blocks at {:d}Hz) from {:s}"54 result_params = total_frames / float(f.samplerate), total_frames, total_frames//f.hop_size, f.samplerate, f.uri53 #result_str = "read {:.2f}s ({:d} frames in {:d} blocks at {:d}Hz) from {:s}" 54 #result_params = total_frames / float(f.samplerate), total_frames, total_frames//f.hop_size, f.samplerate, f.uri 55 55 #print (result_str.format(*result_params)) 56 56 return total_frames … … 102 102 duration = f.duration 103 103 while True: 104 vec, read = f()104 _, read = f() 105 105 total_frames += read 106 106 if read < f.hop_size: break … … 112 112 def test_wrong_file(self): 113 113 with self.assertRaises(RuntimeError): 114 f =source('path_to/unexisting file.mp3')114 source('path_to/unexisting file.mp3') 115 115 116 116 class aubio_source_test_wrong_params_with_file(aubio_source_test_case_base): … … 118 118 def test_wrong_samplerate(self): 119 119 with self.assertRaises(ValueError): 120 f =source(self.default_test_sound, -1)120 source(self.default_test_sound, -1) 121 121 122 122 def test_wrong_hop_size(self): 123 123 with self.assertRaises(ValueError): 124 f =source(self.default_test_sound, 0, -1)124 source(self.default_test_sound, 0, -1) 125 125 126 126 def test_wrong_channels(self): 127 127 with self.assertRaises(ValueError): 128 f =source(self.default_test_sound, 0, 0, -1)128 source(self.default_test_sound, 0, 0, -1) 129 129 130 130 def test_wrong_seek(self): … … 138 138 with self.assertRaises(ValueError): 139 139 f.seek(f.duration + f.samplerate * 10) 140 except AssertionError as e:140 except AssertionError: 141 141 self.skipTest('seeking after end of stream failed raising ValueError') 142 142 … … 146 146 total_frames = 0 147 147 while True: 148 vec, read = f.do_multi()148 _, read = f.do_multi() 149 149 total_frames += read 150 150 if read < f.hop_size: break 151 result_str = "read {:.2f}s ({:d} frames in {:d} channels and {:d} blocks at {:d}Hz) from {:s}"152 result_params = total_frames / float(f.samplerate), total_frames, f.channels, int(total_frames/f.hop_size), f.samplerate, f.uri151 #result_str = "read {:.2f}s ({:d} frames in {:d} channels and {:d} blocks at {:d}Hz) from {:s}" 152 #result_params = total_frames / float(f.samplerate), total_frames, f.channels, int(total_frames/f.hop_size), f.samplerate, f.uri 153 153 #print (result_str.format(*result_params)) 154 154 return total_frames 155 155 156 156 if __name__ == '__main__': 157 from nose2 import main158 157 main()
Note: See TracChangeset
for help on using the changeset viewer.