source: tests/python/src/utils/hist.py @ 0f2084d

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 0f2084d was 66a150a2, checked in by Paul Brossier <piem@piem.org>, 17 years ago

move around files in tests/python according to src/ changes

  • Property mode set to 100644
File size: 1.2 KB
Line 
1import unittest
2
3from template import aubio_unit_template
4from aubio.aubiowrapper import *
5
6buf_size = 2048
7channels = 1
8flow = 0.
9fhig = 100.
10
11nelems = 1000
12
13class hist_unit(aubio_unit_template):
14
15  def setUp(self):
16    self.o = new_aubio_hist(flow, fhig, nelems, channels)
17
18  def tearDown(self):
19    del_aubio_hist(self.o)
20
21  def test_hist(self):
22    """ create and delete hist """
23    pass
24
25  def test_hist_zeroes(self):
26    """ test hist on zeroes """
27    input = new_fvec(buf_size, channels)
28    aubio_hist_do_notnull(self.o, input)
29    aubio_hist_weight(self.o)
30    self.assertEqual(0., aubio_hist_mean(self.o))
31    del_fvec(input)
32
33  def test_hist_impulse(self):
34    """ test hist on impulse """
35    input = new_fvec(buf_size, channels)
36    constant = fhig - 1. 
37    fvec_write_sample(input,constant,0,0)
38    aubio_hist_do_notnull(self.o, input)
39    self.assertCloseEnough(1./nelems, aubio_hist_mean(self.o))
40    del_fvec(input)
41
42  def test_hist_impulse2(self):
43    """ test hist on impulse """
44    input = new_fvec(buf_size, channels)
45    constant = fhig + 1. 
46    fvec_write_sample(input,constant,0,0)
47    aubio_hist_do_notnull(self.o, input)
48    self.assertCloseEnough(1./nelems, aubio_hist_mean(self.o))
49    del_fvec(input)
50
51if __name__ == '__main__': unittest.main()
Note: See TracBrowser for help on using the repository browser.