History

tests/python/: removed old python tests

Paul Brossier committed 13 years ago

Commit 208336b1 parent f50e53414 files · +19 −191Browse files

Showing the changes to python (2 of 14 files). Show all

Unified · Split

2 files
  1. python/tests/test_hist.py.old +74 −0
  2. python/tests/test_zero_crossing_rate.py.old +56 −0
python/tests/test_hist.py.old+74−0
@@ -0,0 +1,74 @@
1#! /usr/bin/env python
2
3from numpy.testing import TestCase, assert_equal, assert_almost_equal
4from aubio import fvec, digital_filter
5import random
6
7buf_size = 2048
8channels = 1
9flow = float(random.randint(0, 100) + random.random())
10fhig = float(random.randint(100, 1000) + random.random())
11
12nelems = 1000
13
14class hist_test_case(TestCase):
15
16 def setUp(self):
17 self.o = new_aubio_hist(flow, fhig, nelems, channels)
18
19 def tearDown(self):
20 del_aubio_hist(self.o)
21
22 def test_hist(self):
23 """ create and delete hist """
24 pass
25
26 def test_hist_zeroes(self):
27 """ test hist on zeroes """
28 input = new_fvec(buf_size, channels)
29 aubio_hist_do_notnull(self.o, input)
30 aubio_hist_weight(self.o)
31 self.assertEqual(0., aubio_hist_mean(self.o))
32 del_fvec(input)
33
34 def test_hist_impulse_top(self):
35 """ test hist on impulse (top - 1.) """
36 """ this returns 1./nelems because 1 element is in the range """
37 input = new_fvec(buf_size, channels)
38 constant = fhig - 1.
39 fvec_write_sample(input,constant,0,0)
40 aubio_hist_do_notnull(self.o, input)
41 self.assertCloseEnough(1./nelems, aubio_hist_mean(self.o))
42 del_fvec(input)
43
44 def test_hist_impulse_over(self):
45 """ test hist on impulse (top + 1.) """
46 """ this returns 0 because constant is out of range """
47 input = new_fvec(buf_size, channels)
48 constant = fhig + 1.
49 fvec_write_sample(input,constant,0,0)
50 aubio_hist_do_notnull(self.o, input)
51 self.assertCloseEnough(0., aubio_hist_mean(self.o))
52 del_fvec(input)
53
54 def test_hist_impulse_bottom(self):
55 """ test hist on constant near lower limit """
56 """ this returns 1./nelems because 1 element is in the range """
57 input = new_fvec(buf_size, channels)
58 constant = flow + 1.
59 fvec_write_sample(input,constant,0,0)
60 aubio_hist_do_notnull(self.o, input)
61 self.assertCloseEnough(1./nelems, aubio_hist_mean(self.o))
62 del_fvec(input)
63
64 def test_hist_impulse_under(self):
65 """ test hist on constant under lower limit """
66 """ this returns 0 because constant is out of range """
67 vec_in = fvec(buf_size)
68 constant = flow - 1.
69 vec_in[0] = constant
70 aubio_hist_do_notnull(self.o, input)
71 self.assertCloseEnough(0., aubio_hist_mean(self.o))
72 del_fvec(input)
73
74if __name__ == '__main__': unittest.main()
python/tests/test_zero_crossing_rate.py.old+56−0
@@ -0,0 +1,56 @@
1from aubio import zero_crossing_rate
2
3#! /usr/bin/env python
4
5from numpy.testing import TestCase
6
7buf_size = 2048
8channels = 1
9
10class zero_crossing_rate_test_case(TestCase):
11
12 def setUp(self):
13 self.vector = new_fvec(buf_size, channels)
14
15 def tearDown(self):
16 del_fvec(self.vector)
17
18 def test(self):
19 """ create and delete fvec """
20 pass
21
22 def test_zeroes(self):
23 """ check zero crossing rate on a buffer of 0. """
24 self.assertEqual(0., zero_crossing_rate(self.vector))
25
26 def test_ones(self):
27 """ check zero crossing rate on a buffer of 1. """
28 for index in range(buf_size):
29 for channel in range(channels):
30 fvec_write_sample(self.vector, 1., channel, index)
31 self.assertEqual(0., zero_crossing_rate(self.vector))
32
33 def test_impulse(self):
34 """ check zero crossing rate on a buffer with an impulse """
35 fvec_write_sample(self.vector, 1., 0, buf_size / 2)
36 self.assertEqual(0., zero_crossing_rate(self.vector))
37
38 def test_negative_impulse(self):
39 """ check zero crossing rate on a buffer with a negative impulse """
40 fvec_write_sample(self.vector, -1., 0, buf_size / 2)
41 self.assertEqual(2./buf_size, zero_crossing_rate(self.vector))
42
43 def test_single(self):
44 """ check zero crossing rate on single crossing """
45 fvec_write_sample(self.vector, +1., 0, buf_size / 2 - 1)
46 fvec_write_sample(self.vector, -1., 0, buf_size / 2)
47 self.assertEqual(2./buf_size, zero_crossing_rate(self.vector))
48
49 def test_single_with_gap(self):
50 """ check zero crossing rate on single crossing with a gap"""
51 fvec_write_sample(self.vector, +1., 0, buf_size / 2 - 2)
52 fvec_write_sample(self.vector, -1., 0, buf_size / 2)
53 self.assertEqual(2./buf_size, zero_crossing_rate(self.vector))
54
55if __name__ == '__main__':
56 unittest.main()

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t