Changeset 2a14820
 Timestamp:
 May 2, 2016, 2:51:32 PM (4 years ago)
 Branches:
 feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
 Children:
 cdfad0c6
 Parents:
 37ca459
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

python/tests/test_filterbank.py
r37ca459 r2a14820 1 1 #! /usr/bin/env python 2 2 3 from numpy.testing import TestCase , run_module_suite3 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 … … 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()) … … 24 22 f = filterbank(40, 512) 25 23 c = cvec(512) 26 c.phas[:] = pi24 c.phas[:] = np.pi 27 25 assert_equal( f(c), 0); 28 26 … … 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 ) … … 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 ) … … 64 63 65 64 if __name__ == '__main__': 66 from unittestimport main67 main()65 from nose2 import main 66 main() 68 67
Note: See TracChangeset
for help on using the changeset viewer.