source: python/tests/test_cvec.py @ aba718a

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

python/tests/test_cvec.py: remove whitespace and unused variable (closes #19), thanks to SivaCoHan?

  • 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        shape(a.norm)
13        shape(a.phas)
14        a.norm[0]
15        assert_equal(a.norm, 0.)
16        assert_equal(a.phas, 0.)
17
18    def test_vector_assign_element(self):
19        a = cvec()
20        a.norm[0] = 1
21        assert_equal(a.norm[0], 1)
22        a.phas[0] = 1
23        assert_equal(a.phas[0], 1)
24
25    def test_vector_assign_element_end(self):
26        a = cvec()
27        a.norm[-1] = 1
28        assert_equal(a.norm[-1], 1)
29        assert_equal(a.norm[len(a.norm)-1], 1)
30        a.phas[-1] = 1
31        assert_equal(a.phas[-1], 1)
32        assert_equal(a.phas[len(a.phas)-1], 1)
33
34    def test_assign_cvec_norm_slice(self):
35        spec = cvec(1024)
36        spec.norm[40:100] = 100
37        assert_equal(spec.norm[0:40], 0)
38        assert_equal(spec.norm[40:100], 100)
39        assert_equal(spec.norm[100:-1], 0)
40        assert_equal(spec.phas, 0)
41
42    def test_assign_cvec_phas_slice(self):
43        spec = cvec(1024)
44        spec.phas[39:-1] = -pi
45        assert_equal(spec.phas[0:39], 0)
46        assert_equal(spec.phas[39:-1], -pi)
47        assert_equal(spec.norm, 0)
48
49if __name__ == '__main__':
50    from unittest import main
51    main()
Note: See TracBrowser for help on using the repository browser.