source: python/tests/test_hist.py.old @ 9ee1ee9

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 9ee1ee9 was 208336b, checked in by Paul Brossier <piem@piem.org>, 12 years ago

tests/python/: removed old python tests

  • Property mode set to 100644
File size: 2.3 KB
Line 
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()
Note: See TracBrowser for help on using the repository browser.