Showing the changes to python/tests (1 of 1 file). Show all
Unified · Split
| @@ -1,10 +1,8 @@ | ||
| 1 | 1 | #! /usr/bin/env python |
| 2 | 2 | |
| 3 | −from numpy.testing import TestCase, run_module_suite | |
| 3 | +from numpy.testing import TestCase | |
| 4 | 4 | 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 | |
| 8 | 6 | from aubio import cvec, filterbank, float_type |
| 9 | 7 | from utils import array_from_text_file |
| 10 | 8 | |
| @@ -16,14 +14,14 @@ class aubio_filterbank_test_case(TestCase): · 5 unmodified lines | ||
| 16 | 14 | |
| 17 | 15 | def test_set_coeffs(self): |
| 18 | 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 | 18 | f.set_coeffs(r) |
| 21 | 19 | assert_equal (r, f.get_coeffs()) |
| 22 | 20 | |
| 23 | 21 | def test_phase(self): |
| 24 | 22 | f = filterbank(40, 512) |
| 25 | 23 | c = cvec(512) |
| 26 | − c.phas[:] = pi | |
| 24 | + c.phas[:] = np.pi | |
| 27 | 25 | assert_equal( f(c), 0); |
| 28 | 26 | |
| 29 | 27 | def test_norm(self): |
| @@ -35,16 +33,17 @@ class aubio_filterbank_test_case(TestCase): · 5 unmodified lines | ||
| 35 | 33 | def test_random_norm(self): |
| 36 | 34 | f = filterbank(40, 512) |
| 37 | 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 | 37 | assert_equal( f(c), 0) |
| 40 | 38 | |
| 41 | 39 | 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) | |
| 45 | 44 | r /= r.sum() |
| 46 | 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 | 47 | assert_equal ( f(c) < 1., True ) |
| 49 | 48 | assert_equal ( f(c) > 0., True ) |
| 50 | 49 | |
| @@ -52,7 +51,7 @@ class aubio_filterbank_test_case(TestCase): · 1 unmodified line | ||
| 52 | 51 | f = filterbank(40, 512) |
| 53 | 52 | c = cvec(512) |
| 54 | 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 | 55 | assert_equal ( f(c) < 1., True ) |
| 57 | 56 | assert_equal ( f(c) > 0., True ) |
| 58 | 57 | |
| @@ -63,6 +62,6 @@ class aubio_filterbank_test_case(TestCase): · 4 unmodified lines | ||
| 63 | 62 | assert_almost_equal ( expected, f.get_coeffs() ) |
| 64 | 63 | |
| 65 | 64 | if __name__ == '__main__': |
| 66 | − from unittest import main | |
| 67 | − main() | |
| 65 | + from nose2 import main | |
| 66 | + main() | |
| 68 | 67 | |