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/tests (1 of 1 file). Show all

Unified · Split

python/tests/test_filterbank.py+13−14
@@ -1,10 +1,8 @@
11 #! /usr/bin/env python
22
3−from numpy.testing import TestCase, run_module_suite
3+from numpy.testing import TestCase
44 from numpy.testing import assert_equal, assert_almost_equal
5−from numpy import random
6−from math import pi
7−from numpy import array
5+import numpy as np
86 from aubio import cvec, filterbank, float_type
97 from utils import array_from_text_file
108
@@ -16,14 +14,14 @@ class aubio_filterbank_test_case(TestCase): · 5 unmodified lines
1614
1715 def test_set_coeffs(self):
1816 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)
2018 f.set_coeffs(r)
2119 assert_equal (r, f.get_coeffs())
2220
2321 def test_phase(self):
2422 f = filterbank(40, 512)
2523 c = cvec(512)
26− c.phas[:] = pi
24+ c.phas[:] = np.pi
2725 assert_equal( f(c), 0);
2826
2927 def test_norm(self):
@@ -35,16 +33,17 @@ class aubio_filterbank_test_case(TestCase): · 5 unmodified lines
3533 def test_random_norm(self):
3634 f = filterbank(40, 512)
3735 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)
3937 assert_equal( f(c), 0)
4038
4139 def test_random_coeffs(self):
42− f = filterbank(40, 512)
43− c = cvec(512)
44− r = random.random([40, int(512 / 2) + 1]).astype(float_type)
40+ win_s = 128
41+ f = filterbank(40, win_s)
42+ c = cvec(win_s)
43+ r = np.random.random([40, int(win_s / 2) + 1]).astype(float_type)
4544 r /= r.sum()
4645 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)
4847 assert_equal ( f(c) < 1., True )
4948 assert_equal ( f(c) > 0., True )
5049
@@ -52,7 +51,7 @@ class aubio_filterbank_test_case(TestCase): · 1 unmodified line
5251 f = filterbank(40, 512)
5352 c = cvec(512)
5453 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)
5655 assert_equal ( f(c) < 1., True )
5756 assert_equal ( f(c) > 0., True )
5857
@@ -63,6 +62,6 @@ class aubio_filterbank_test_case(TestCase): · 4 unmodified lines
6362 assert_almost_equal ( expected, f.get_coeffs() )
6463
6564 if __name__ == '__main__':
66− from unittest import main
67− main()
65+ from nose2 import main
66+ main()
6867

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