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_automatic_sizes_default(self):
12 assert_equal ([f.win_s, f.hop_s], [1024, 512])
14 def test_members_automatic_sizes_not_null(self):
16 assert_equal ([f.win_s, f.hop_s], [2048, 128])
19 win_s, hop_s = 1024, 256
20 f = pvoc (win_s, hop_s)
22 for time in range( 4 * win_s / hop_s ):
25 assert_equal ( array(t), 0)
26 assert_equal ( s.norm, 0)
27 assert_equal ( s.phas, 0)
30 def test_steps_two_channels(self):
31 """ check the resynthesis of steps is correct """
35 # positive step in first channel
37 # positive step in second channel
43 #self.plot_this ( s1.norm.T )
44 assert_almost_equal ( t1, r2, decimal = 6 )
46 def test_steps_three_random_channels(self):
47 from random import random
52 t1[i] = random() * 2. - 1.
57 assert_almost_equal( t1, t2, decimal = 6 )
59 def plot_this( self, this ):
60 from pylab import semilogy, show
64 if __name__ == '__main__':
65 from unittest import main