From: Paul Brossier Date: Sun, 3 Mar 2013 20:33:29 +0000 (-0500) Subject: python/tests/test_filterbank.py: added test against existing coeffs X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=71ef9c20e3523b77d0badf4790eeeb793d9644e1;p=aubio.git python/tests/test_filterbank.py: added test against existing coeffs --- diff --git a/tests/python/src/spectral/filterbank_mfcc_16000_512.txt b/python/tests/filterbank_mfcc_16000_512.expected similarity index 100% rename from tests/python/src/spectral/filterbank_mfcc_16000_512.txt rename to python/tests/filterbank_mfcc_16000_512.expected diff --git a/python/tests/test_filterbank.py b/python/tests/test_filterbank.py index 595d022a..3fd64fd9 100755 --- a/python/tests/test_filterbank.py +++ b/python/tests/test_filterbank.py @@ -4,8 +4,13 @@ from numpy.testing import TestCase, run_module_suite from numpy.testing import assert_equal, assert_almost_equal from numpy import random from math import pi +from numpy import array from aubio import cvec, filterbank +def array_from_text_file(filename, dtype = 'float'): + return array([line.split() for line in open(filename).readlines()], + dtype = dtype) + class aubio_filterbank_test_case(TestCase): def test_members(self): @@ -54,6 +59,12 @@ class aubio_filterbank_test_case(TestCase): assert_equal ( f(c) < 1., True ) assert_equal ( f(c) > 0., True ) + def test_mfcc_coeffs_16000(self): + expected = array_from_text_file('filterbank_mfcc_16000_512.expected') + f = filterbank(40, 512) + f.set_mel_coeffs_slaney(16000) + assert_almost_equal ( expected, f.get_coeffs() ) + if __name__ == '__main__': from unittest import main main()