Changeset 7b7a58e for python/tests
- Timestamp:
- Sep 16, 2017, 11:55:51 PM (7 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
- Children:
- bfbfafa
- Parents:
- b99e2a5 (diff), cfb7fb7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- python/tests
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_filterbank.py
rb99e2a5 r7b7a58e 1 1 #! /usr/bin/env python 2 2 3 from unittest import main4 from numpy.testing import TestCase5 from numpy.testing import assert_equal, assert_almost_equal6 3 import numpy as np 4 from numpy.testing import TestCase, assert_equal, assert_almost_equal 5 7 6 from aubio import cvec, filterbank, float_type 8 7 from .utils import array_from_text_file … … 63 62 assert_almost_equal ( expected, f.get_coeffs() ) 64 63 64 def test_mfcc_coeffs_get_coeffs(self): 65 f = filterbank(40, 512) 66 coeffs = f.get_coeffs() 67 self.assertIsInstance(coeffs, np.ndarray) 68 assert_equal (coeffs, 0) 69 assert_equal (np.shape(coeffs), (40, 512 / 2 + 1)) 70 65 71 class aubio_filterbank_wrong_values(TestCase): 66 72 … … 82 88 83 89 if __name__ == '__main__': 84 main() 90 import nose2 91 nose2.main() -
python/tests/test_filterbank_mel.py
rb99e2a5 r7b7a58e 1 1 #! /usr/bin/env python 2 2 3 from unittest import main 4 from numpy.testing import TestCase 5 from numpy.testing import assert_equal, assert_almost_equal 6 from numpy import array, shape 3 import numpy as np 4 from numpy.testing import TestCase, assert_equal, assert_almost_equal 5 7 6 from aubio import cvec, filterbank, float_type 7 8 import warnings 9 warnings.filterwarnings('ignore', category=UserWarning, append=True) 8 10 9 11 class aubio_filterbank_mel_test_case(TestCase): … … 13 15 f.set_mel_coeffs_slaney(16000) 14 16 a = f.get_coeffs() 15 assert_equal( shape (a), (40, 512/2 + 1) )17 assert_equal(np.shape (a), (40, 512/2 + 1) ) 16 18 17 19 def test_other_slaney(self): 18 20 f = filterbank(40, 512*2) 19 21 f.set_mel_coeffs_slaney(44100) 20 _ = f.get_coeffs()22 self.assertIsInstance(f.get_coeffs(), np.ndarray) 21 23 #print "sum is", sum(sum(a)) 22 24 for win_s in [256, 512, 1024, 2048, 4096]: 23 25 f = filterbank(40, win_s) 24 26 f.set_mel_coeffs_slaney(32000) 25 _ = f.get_coeffs()26 27 #print "sum is", sum(sum(a)) 28 self.assertIsInstance(f.get_coeffs(), np.ndarray) 27 29 28 30 def test_triangle_freqs_zeros(self): 29 31 f = filterbank(9, 1024) 30 32 freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000] 31 freqs = array(freq_list, dtype = float_type)33 freqs = np.array(freq_list, dtype = float_type) 32 34 f.set_triangle_bands(freqs, 48000) 33 _ = f.get_coeffs().T34 35 assert_equal ( f(cvec(1024)), 0) 36 self.assertIsInstance(f.get_coeffs(), np.ndarray) 35 37 36 38 def test_triangle_freqs_ones(self): 37 39 f = filterbank(9, 1024) 38 40 freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000] 39 freqs = array(freq_list, dtype = float_type)41 freqs = np.array(freq_list, dtype = float_type) 40 42 f.set_triangle_bands(freqs, 48000) 41 _ = f.get_coeffs().T43 self.assertIsInstance(f.get_coeffs(), np.ndarray) 42 44 spec = cvec(1024) 43 45 spec.norm[:] = 1 … … 47 49 48 50 if __name__ == '__main__': 49 main() 51 import nose2 52 nose2.main()
Note: See TracChangeset
for help on using the changeset viewer.