Changeset 5e3ed60 for interfaces/python/test_filterbank.py
- Timestamp:
- Jul 12, 2012, 1:39:40 AM (12 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:
- 1ebf8770, 913ee14
- Parents:
- f6cbefe
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
interfaces/python/test_filterbank.py
-
Property
mode
changed from
100644
to100755
rf6cbefe r5e3ed60 1 #! /usr/bin/python 2 1 3 from numpy.testing import TestCase, run_module_suite 2 4 from numpy.testing import assert_equal, assert_almost_equal 3 from numpy import array, shape5 from numpy import random 4 6 from aubio import cvec, filterbank 5 7 6 class aubio_filter _test_case(TestCase):8 class aubio_filterbank_test_case(TestCase): 7 9 8 def test_ slaney(self):10 def test_members(self): 9 11 f = filterbank(40, 512) 10 f.set_mel_coeffs_slaney(16000) 11 a = f.get_coeffs() 12 a.T 13 assert_equal(shape (a), (40, 512/2 + 1) ) 12 assert_equal ([f.n_filters, f.win_s], [40, 512]) 14 13 15 def test_other_slaney(self): 16 f = filterbank(40, 512*2) 17 f.set_mel_coeffs_slaney(44100) 18 a = f.get_coeffs() 19 #print "sum is", sum(sum(a)) 20 for win_s in [256, 512, 1024, 2048, 4096]: 21 f = filterbank(40, win_s) 22 f.set_mel_coeffs_slaney(320000) 23 a = f.get_coeffs() 24 #print "sum is", sum(sum(a)) 25 26 def test_triangle_freqs_zeros(self): 27 f = filterbank(9, 1024) 28 freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000] 29 freqs = array(freq_list, dtype = 'float32') 30 f.set_triangle_bands(freqs, 48000) 31 f.get_coeffs().T 32 assert_equal ( f(cvec(1024)), 0) 33 34 def test_triangle_freqs_ones(self): 35 f = filterbank(9, 1024) 36 freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000] 37 freqs = array(freq_list, dtype = 'float32') 38 f.set_triangle_bands(freqs, 48000) 39 f.get_coeffs().T 40 spec = cvec(1024) 41 spec.norm[:] = 1 42 assert_almost_equal ( f(spec), 43 [ 0.02070313, 0.02138672, 0.02127604, 0.02135417, 44 0.02133301, 0.02133301, 0.02133311, 0.02133334, 0.02133345]) 14 def test_set_coeffs(self): 15 f = filterbank(40, 512) 16 r = random.random([40, 512 / 2 + 1]).astype('float32') 17 f.set_coeffs(r) 18 assert_equal (r, f.get_coeffs()) 45 19 46 20 if __name__ == '__main__': -
Property
mode
changed from
Note: See TracChangeset
for help on using the changeset viewer.