Changeset ece990f
- Timestamp:
- May 11, 2016, 2:53:11 AM (9 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:
- 34d0c25
- Parents:
- 2871e2b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/test_filter.py
r2871e2b rece990f 8 8 class aubio_filter_test_case(TestCase): 9 9 10 def test_members(self): 11 f = digital_filter() 12 assert_equal (f.order, 7) 13 f = digital_filter(5) 14 assert_equal (f.order, 5) 15 f(fvec()) 16 17 def test_cweighting_error(self): 18 f = digital_filter (2) 19 self.assertRaises ( ValueError, f.set_c_weighting, 44100 ) 20 f = digital_filter (8) 21 self.assertRaises ( ValueError, f.set_c_weighting, 44100 ) 22 f = digital_filter (5) 23 self.assertRaises ( ValueError, f.set_c_weighting, 4000 ) 24 f = digital_filter (5) 25 self.assertRaises ( ValueError, f.set_c_weighting, 193000 ) 26 f = digital_filter (7) 27 self.assertRaises ( ValueError, f.set_a_weighting, 193000 ) 28 f = digital_filter (5) 29 self.assertRaises ( ValueError, f.set_a_weighting, 192000 ) 10 def test_members(self): 11 f = digital_filter() 12 assert_equal (f.order, 7) 13 f = digital_filter(5) 14 assert_equal (f.order, 5) 15 f(fvec()) 30 16 31 def test_c_weighting(self): 32 expected = array_from_text_file('c_weighting_test_simple.expected') 33 f = digital_filter(5) 34 f.set_c_weighting(44100) 35 v = fvec(32) 36 v[12] = .5 37 u = f(v) 38 assert_almost_equal (expected[1], u) 17 def test_cweighting_error(self): 18 f = digital_filter (2) 19 self.assertRaises ( ValueError, f.set_c_weighting, 44100 ) 20 f = digital_filter (8) 21 self.assertRaises ( ValueError, f.set_c_weighting, 44100 ) 22 f = digital_filter (5) 23 self.assertRaises ( ValueError, f.set_c_weighting, 4000 ) 24 f = digital_filter (5) 25 self.assertRaises ( ValueError, f.set_c_weighting, 193000 ) 26 f = digital_filter (7) 27 self.assertRaises ( ValueError, f.set_a_weighting, 193000 ) 28 f = digital_filter (5) 29 self.assertRaises ( ValueError, f.set_a_weighting, 192000 ) 39 30 40 def test_c_weighting_8000(self):41 expected = array_from_text_file('c_weighting_test_simple_8000.expected')42 f = digital_filter(5)43 f.set_c_weighting(8000)44 v = fvec(32)45 v[12] = .546 u = f(v)47 assert_almost_equal (expected[1], u)31 def test_c_weighting(self): 32 expected = array_from_text_file('c_weighting_test_simple.expected') 33 f = digital_filter(5) 34 f.set_c_weighting(44100) 35 v = fvec(32) 36 v[12] = .5 37 u = f(v) 38 assert_almost_equal (expected[1], u) 48 39 49 def test_a_weighting(self):50 expected = array_from_text_file('a_weighting_test_simple.expected')51 f = digital_filter(7)52 f.set_a_weighting(44100)53 v = fvec(32)54 v[12] = .555 u = f(v)56 assert_almost_equal (expected[1], u)40 def test_c_weighting_8000(self): 41 expected = array_from_text_file('c_weighting_test_simple_8000.expected') 42 f = digital_filter(5) 43 f.set_c_weighting(8000) 44 v = fvec(32) 45 v[12] = .5 46 u = f(v) 47 assert_almost_equal (expected[1], u) 57 48 58 def test_a_weighting_parted(self): 59 expected = array_from_text_file('a_weighting_test_simple.expected') 60 f = digital_filter(7) 61 f.set_a_weighting(44100) 62 v = fvec(16) 63 v[12] = .5 64 u = f(v) 65 assert_almost_equal (expected[1][:16], u) 66 # one more time 67 v = fvec(16) 68 u = f(v) 69 assert_almost_equal (expected[1][16:], u) 49 def test_a_weighting(self): 50 expected = array_from_text_file('a_weighting_test_simple.expected') 51 f = digital_filter(7) 52 f.set_a_weighting(44100) 53 v = fvec(32) 54 v[12] = .5 55 u = f(v) 56 assert_almost_equal (expected[1], u) 70 57 71 def test_set_biquad(self): 72 f = digital_filter(3) 73 f.set_biquad(0., 0., 0, 0., 0.) 58 def test_a_weighting_parted(self): 59 expected = array_from_text_file('a_weighting_test_simple.expected') 60 f = digital_filter(7) 61 f.set_a_weighting(44100) 62 v = fvec(16) 63 v[12] = .5 64 u = f(v) 65 assert_almost_equal (expected[1][:16], u) 66 # one more time 67 v = fvec(16) 68 u = f(v) 69 assert_almost_equal (expected[1][16:], u) 74 70 75 def test_set_biquad_wrong_order(self): 76 f = digital_filter(4) 77 with self.assertRaises(ValueError): 71 def test_set_biquad(self): 72 f = digital_filter(3) 78 73 f.set_biquad(0., 0., 0, 0., 0.) 74 75 def test_set_biquad_wrong_order(self): 76 f = digital_filter(4) 77 with self.assertRaises(ValueError): 78 f.set_biquad(0., 0., 0, 0., 0.) 79 79 80 80 class aubio_filter_wrong_params(TestCase):
Note: See TracChangeset
for help on using the changeset viewer.