Changeset e7556a1
- Timestamp:
- Sep 16, 2017, 11:46:30 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:
- b99e2a5
- Parents:
- c96e6c0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_dct.py
rc96e6c0 re7556a1 6 6 import aubio 7 7 8 precomputed_arange = [ 9.89949512, -6.44232273, 0., -0.67345482, 0., 9 -0.20090288, 0., -0.05070186] 10 11 precomputed_some_ones = [ 4.28539848, 0.2469689, -0.14625292, -0.58121818, 12 -0.83483052, -0.75921834, -0.35168475, 0.24087936, 13 0.78539824, 1.06532764, 0.97632152, 0.57164496, 0.03688532, 14 -0.39446154, -0.54619485, -0.37771079] 15 8 16 class aubio_dct(TestCase): 9 17 10 18 def test_init(self): 11 """ check aubio.dct() can be created"""19 """ test that aubio.dct() is created with expected size """ 12 20 a_dct = aubio.dct() 13 21 self.assertEqual(a_dct.size, 1024) … … 20 28 >>> precomputed = dct(a_in, norm='ortho') 21 29 """ 22 precomputed = [ 9.89949512, -6.44232273, 0., -0.67345482, 0., 23 -0.20090288, 0., -0.05070186] 30 N = len(precomputed_arange) 24 31 a_dct = aubio.dct(8) 25 32 a_in = np.arange(8).astype('float32') 26 a_expected = aubio.fvec(precomputed )33 a_expected = aubio.fvec(precomputed_arange) 27 34 assert_almost_equal(a_dct(a_in), a_expected, decimal=6) 28 35 29 36 def test_some_ones(self): 30 37 """ test that dct(somevector) is computed correctly """ 31 precomputed = [ 4.28539848, 0.2469689, -0.14625292, -0.58121818,32 -0.83483052, -0.75921834, -0.35168475, 0.24087936,33 0.78539824, 1.06532764, 0.97632152, 0.57164496, 0.03688532,34 -0.39446154, -0.54619485, -0.37771079]35 38 a_dct = aubio.dct(16) 36 39 a_in = np.ones(16).astype('float32') 37 40 a_in[1] = 0 38 41 a_in[3] = np.pi 39 a_expected = aubio.fvec(precomputed )42 a_expected = aubio.fvec(precomputed_some_ones) 40 43 assert_almost_equal(a_dct(a_in), a_expected, decimal=7) 41 44 42 45 def test_reconstruction(self): 46 """ test that some_ones vector can be recontructed """ 43 47 a_dct = aubio.dct(16) 44 48 a_in = np.ones(16).astype('float32') … … 50 54 51 55 def test_negative_size(self): 56 """ test that creation fails with a negative size """ 52 57 with self.assertRaises(ValueError): 53 58 aubio.dct(-1) 54 59 55 60 def test_wrong_size(self): 61 """ test that creation fails with a non power-of-two size """ 56 62 # supports for non 2** fft sizes only when compiled with fftw3 57 63 try:
Note: See TracChangeset
for help on using the changeset viewer.