3 from numpy.testing import TestCase, run_module_suite
4 from numpy.testing import assert_equal, assert_almost_equal
5 from aubio import fvec, cvec, pvoc
6 from numpy import array, shape
8 class aubio_pvoc_test_case(TestCase):
10 def test_members(self):
12 assert_equal ([f.win_s, f.hop_s], [1024, 512])
14 assert_equal ([f.win_s, f.hop_s], [2048, 128])
17 win_s, hop_s = 1024, 256
18 f = pvoc (win_s, hop_s)
20 for time in range( 4 * win_s / hop_s ):
23 assert_equal ( array(t), 0)
24 assert_equal ( s.norm, 0)
25 assert_equal ( s.phas, 0)
28 def test_steps_two_channels(self):
29 """ check the resynthesis of steps is correct """
33 # positive step in first channel
35 # positive step in second channel
41 #self.plot_this ( s1.norm.T )
42 assert_almost_equal ( t1, r2, decimal = 6 )
44 def test_steps_three_random_channels(self):
45 from random import random
50 t1[i] = random() * 2. - 1.
55 assert_almost_equal( t1, t2, decimal = 6 )
57 def plot_this( self, this ):
58 from pylab import semilogy, show
62 if __name__ == '__main__':
63 from unittest import main