source: python/tests/test_cvec.py @ dc467b5d

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

tests/test_cvec.py: add missing header

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