source: python/tests/test_cvec.py @ a4cc8e5

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

moved tests to subdirectory

  • Property mode set to 100755
File size: 1.4 KB
Line 
1from numpy.testing import TestCase, run_module_suite
2from numpy.testing import assert_equal, assert_almost_equal
3from aubio import cvec
4from numpy import array, shape, pi
5
6class aubio_cvec_test_case(TestCase):
7
8    def test_vector_created_with_zeroes(self):
9        a = cvec(10)
10        a
11        shape(a.norm)
12        shape(a.phas)
13        a.norm[0]
14        assert_equal(a.norm, 0.)
15        assert_equal(a.phas, 0.)
16
17    def test_vector_assign_element(self):
18        a = cvec()
19        a.norm[0] = 1
20        assert_equal(a.norm[0], 1)
21        a.phas[0] = 1
22        assert_equal(a.phas[0], 1)
23
24    def test_vector_assign_element_end(self):
25        a = cvec()
26        a.norm[-1] = 1
27        assert_equal(a.norm[-1], 1)
28        assert_equal(a.norm[len(a.norm)-1], 1)
29        a.phas[-1] = 1
30        assert_equal(a.phas[-1], 1)
31        assert_equal(a.phas[len(a.phas)-1], 1)
32
33    def test_assign_cvec_norm_slice(self):
34        spec = cvec(1024)
35        spec.norm[40:100] = 100
36        assert_equal (spec.norm[0:40], 0)
37        assert_equal (spec.norm[40:100], 100)
38        assert_equal (spec.norm[100:-1], 0)
39        assert_equal (spec.phas, 0)
40
41    def test_assign_cvec_phas_slice(self):
42        spec = cvec(1024)
43        spec.phas[39:-1] = -pi
44        assert_equal (spec.phas[0:39], 0)
45        assert_equal (spec.phas[39:-1], -pi)
46        assert_equal (spec.norm, 0)
47
48if __name__ == '__main__':
49    from unittest import main
50    main()
Note: See TracBrowser for help on using the repository browser.