Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -8,58 +8,58 @@ from utils import array_from_text_file · 7 unmodified lines | ||
| 8 | 8 | |
| 9 | 9 | class aubio_filterbank_test_case(TestCase): |
| 10 | 10 | |
| 11 | − def test_members(self): | |
| 12 | − f = filterbank(40, 512) | |
| 13 | − assert_equal ([f.n_filters, f.win_s], [40, 512]) | |
| 11 | + def test_members(self): | |
| 12 | + f = filterbank(40, 512) | |
| 13 | + assert_equal ([f.n_filters, f.win_s], [40, 512]) | |
| 14 | 14 | |
| 15 | − def test_set_coeffs(self): | |
| 16 | − f = filterbank(40, 512) | |
| 17 | − r = np.random.random([40, int(512 / 2) + 1]).astype(float_type) | |
| 18 | − f.set_coeffs(r) | |
| 19 | − assert_equal (r, f.get_coeffs()) | |
| 15 | + def test_set_coeffs(self): | |
| 16 | + f = filterbank(40, 512) | |
| 17 | + r = np.random.random([40, int(512 / 2) + 1]).astype(float_type) | |
| 18 | + f.set_coeffs(r) | |
| 19 | + assert_equal (r, f.get_coeffs()) | |
| 20 | 20 | |
| 21 | − def test_phase(self): | |
| 22 | − f = filterbank(40, 512) | |
| 23 | − c = cvec(512) | |
| 24 | − c.phas[:] = np.pi | |
| 25 | − assert_equal( f(c), 0); | |
| 21 | + def test_phase(self): | |
| 22 | + f = filterbank(40, 512) | |
| 23 | + c = cvec(512) | |
| 24 | + c.phas[:] = np.pi | |
| 25 | + assert_equal( f(c), 0); | |
| 26 | 26 | |
| 27 | − def test_norm(self): | |
| 28 | − f = filterbank(40, 512) | |
| 29 | − c = cvec(512) | |
| 30 | − c.norm[:] = 1 | |
| 31 | − assert_equal( f(c), 0); | |
| 27 | + def test_norm(self): | |
| 28 | + f = filterbank(40, 512) | |
| 29 | + c = cvec(512) | |
| 30 | + c.norm[:] = 1 | |
| 31 | + assert_equal( f(c), 0); | |
| 32 | 32 | |
| 33 | − def test_random_norm(self): | |
| 34 | − f = filterbank(40, 512) | |
| 35 | − c = cvec(512) | |
| 36 | − c.norm[:] = np.random.random((int(512 / 2) + 1,)).astype(float_type) | |
| 37 | − assert_equal( f(c), 0) | |
| 33 | + def test_random_norm(self): | |
| 34 | + f = filterbank(40, 512) | |
| 35 | + c = cvec(512) | |
| 36 | + c.norm[:] = np.random.random((int(512 / 2) + 1,)).astype(float_type) | |
| 37 | + assert_equal( f(c), 0) | |
| 38 | 38 | |
| 39 | − def test_random_coeffs(self): | |
| 40 | − win_s = 128 | |
| 41 | − f = filterbank(40, win_s) | |
| 42 | − c = cvec(win_s) | |
| 43 | − r = np.random.random([40, int(win_s / 2) + 1]).astype(float_type) | |
| 44 | − r /= r.sum() | |
| 45 | − f.set_coeffs(r) | |
| 46 | − c.norm[:] = np.random.random((int(win_s / 2) + 1,)).astype(float_type) | |
| 47 | − assert_equal ( f(c) < 1., True ) | |
| 48 | − assert_equal ( f(c) > 0., True ) | |
| 39 | + def test_random_coeffs(self): | |
| 40 | + win_s = 128 | |
| 41 | + f = filterbank(40, win_s) | |
| 42 | + c = cvec(win_s) | |
| 43 | + r = np.random.random([40, int(win_s / 2) + 1]).astype(float_type) | |
| 44 | + r /= r.sum() | |
| 45 | + f.set_coeffs(r) | |
| 46 | + c.norm[:] = np.random.random((int(win_s / 2) + 1,)).astype(float_type) | |
| 47 | + assert_equal ( f(c) < 1., True ) | |
| 48 | + assert_equal ( f(c) > 0., True ) | |
| 49 | 49 | |
| 50 | − def test_mfcc_coeffs(self): | |
| 51 | − f = filterbank(40, 512) | |
| 52 | − c = cvec(512) | |
| 53 | − f.set_mel_coeffs_slaney(44100) | |
| 54 | − c.norm[:] = np.random.random((int(512 / 2) + 1,)).astype(float_type) | |
| 55 | − assert_equal ( f(c) < 1., True ) | |
| 56 | − assert_equal ( f(c) > 0., True ) | |
| 50 | + def test_mfcc_coeffs(self): | |
| 51 | + f = filterbank(40, 512) | |
| 52 | + c = cvec(512) | |
| 53 | + f.set_mel_coeffs_slaney(44100) | |
| 54 | + c.norm[:] = np.random.random((int(512 / 2) + 1,)).astype(float_type) | |
| 55 | + assert_equal ( f(c) < 1., True ) | |
| 56 | + assert_equal ( f(c) > 0., True ) | |
| 57 | 57 | |
| 58 | − def test_mfcc_coeffs_16000(self): | |
| 59 | − expected = array_from_text_file('filterbank_mfcc_16000_512.expected') | |
| 60 | − f = filterbank(40, 512) | |
| 61 | − f.set_mel_coeffs_slaney(16000) | |
| 62 | − assert_almost_equal ( expected, f.get_coeffs() ) | |
| 58 | + def test_mfcc_coeffs_16000(self): | |
| 59 | + expected = array_from_text_file('filterbank_mfcc_16000_512.expected') | |
| 60 | + f = filterbank(40, 512) | |
| 61 | + f.set_mel_coeffs_slaney(16000) | |
| 62 | + assert_almost_equal ( expected, f.get_coeffs() ) | |
| 63 | 63 | |
| 64 | 64 | if __name__ == '__main__': |
| 65 | 65 | from nose2 import main |