History

python/tests/test_filterbank.py: clean up, use nose2

Paul Brossier committed 10 years ago

Commit 2a148201 parent 37ca4591 file · +13 −14Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/tests/test_filterbank.py+13−14
@@ -1,10 +1,8 @@
1#! /usr/bin/env python1#! /usr/bin/env python
2 2
3from numpy.testing import TestCase, run_module_suite3from numpy.testing import TestCase
4from numpy.testing import assert_equal, assert_almost_equal4from numpy.testing import assert_equal, assert_almost_equal
5from numpy import random5import numpy as np
6from math import pi
7from numpy import array
8from aubio import cvec, filterbank, float_type6from aubio import cvec, filterbank, float_type
9from utils import array_from_text_file7from utils import array_from_text_file
10 8
@@ -16,14 +14,14 @@ class aubio_filterbank_test_case(TestCase): · 5 unmodified lines
16 14
17 def test_set_coeffs(self):15 def test_set_coeffs(self):
18 f = filterbank(40, 512)16 f = filterbank(40, 512)
19 r = random.random([40, int(512 / 2) + 1]).astype(float_type)17 r = np.random.random([40, int(512 / 2) + 1]).astype(float_type)
20 f.set_coeffs(r)18 f.set_coeffs(r)
21 assert_equal (r, f.get_coeffs())19 assert_equal (r, f.get_coeffs())
22 20
23 def test_phase(self):21 def test_phase(self):
24 f = filterbank(40, 512)22 f = filterbank(40, 512)
25 c = cvec(512)23 c = cvec(512)
26 c.phas[:] = pi24 c.phas[:] = np.pi
27 assert_equal( f(c), 0);25 assert_equal( f(c), 0);
28 26
29 def test_norm(self):27 def test_norm(self):
@@ -35,16 +33,17 @@ class aubio_filterbank_test_case(TestCase): · 5 unmodified lines
35 def test_random_norm(self):33 def test_random_norm(self):
36 f = filterbank(40, 512)34 f = filterbank(40, 512)
37 c = cvec(512)35 c = cvec(512)
38 c.norm[:] = random.random((int(512 / 2) + 1,)).astype(float_type)36 c.norm[:] = np.random.random((int(512 / 2) + 1,)).astype(float_type)
39 assert_equal( f(c), 0)37 assert_equal( f(c), 0)
40 38
41 def test_random_coeffs(self):39 def test_random_coeffs(self):
42 f = filterbank(40, 512)40 win_s = 128
43 c = cvec(512)41 f = filterbank(40, win_s)
44 r = random.random([40, int(512 / 2) + 1]).astype(float_type)42 c = cvec(win_s)
43 r = np.random.random([40, int(win_s / 2) + 1]).astype(float_type)
45 r /= r.sum()44 r /= r.sum()
46 f.set_coeffs(r)45 f.set_coeffs(r)
47 c.norm[:] = random.random((int(512 / 2) + 1,)).astype(float_type)46 c.norm[:] = np.random.random((int(win_s / 2) + 1,)).astype(float_type)
48 assert_equal ( f(c) < 1., True )47 assert_equal ( f(c) < 1., True )
49 assert_equal ( f(c) > 0., True )48 assert_equal ( f(c) > 0., True )
50 49
@@ -52,7 +51,7 @@ class aubio_filterbank_test_case(TestCase): · 1 unmodified line
52 f = filterbank(40, 512)51 f = filterbank(40, 512)
53 c = cvec(512)52 c = cvec(512)
54 f.set_mel_coeffs_slaney(44100)53 f.set_mel_coeffs_slaney(44100)
55 c.norm[:] = random.random((int(512 / 2) + 1,)).astype(float_type)54 c.norm[:] = np.random.random((int(512 / 2) + 1,)).astype(float_type)
56 assert_equal ( f(c) < 1., True )55 assert_equal ( f(c) < 1., True )
57 assert_equal ( f(c) > 0., True )56 assert_equal ( f(c) > 0., True )
58 57
@@ -63,6 +62,6 @@ class aubio_filterbank_test_case(TestCase): · 4 unmodified lines
63 assert_almost_equal ( expected, f.get_coeffs() )62 assert_almost_equal ( expected, f.get_coeffs() )
64 63
65if __name__ == '__main__':64if __name__ == '__main__':
66 from unittest import main65 from nose2 import main
67 main()66 main()
68 67

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t