Changeset e116e19


Ignore:
Timestamp:
Sep 14, 2017, 4:33:21 PM (2 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
Children:
9a52962
Parents:
c4fc0f2
Message:

python/tests/test_filterbank*.py: clean-up, improve get_coeff tests

Location:
python/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_filterbank.py

    rc4fc0f2 re116e19  
    11#! /usr/bin/env python
    22
    3 from unittest import main
    4 from numpy.testing import TestCase
    5 from numpy.testing import assert_equal, assert_almost_equal
    63import numpy as np
     4from numpy.testing import TestCase, assert_equal, assert_almost_equal
     5
    76from aubio import cvec, filterbank, float_type
    87from .utils import array_from_text_file
     
    6362        assert_almost_equal ( expected, f.get_coeffs() )
    6463
     64    def test_mfcc_coeffs_get_coeffs(self):
     65        f = filterbank(40, 512)
     66        coeffs = f.get_coeffs()
     67        self.assertIsInstance(coeffs, np.ndarray)
     68        assert_equal (coeffs, 0)
     69        assert_equal (np.shape(coeffs), (40, 512 / 2 + 1))
     70
    6571class aubio_filterbank_wrong_values(TestCase):
    6672
     
    8288
    8389if __name__ == '__main__':
    84     main()
     90    import nose2
     91    nose2.main()
  • python/tests/test_filterbank_mel.py

    rc4fc0f2 re116e19  
    11#! /usr/bin/env python
    22
    3 from unittest import main
    4 from numpy.testing import TestCase
    5 from numpy.testing import assert_equal, assert_almost_equal
    6 from numpy import array, shape
     3import numpy as np
     4from numpy.testing import TestCase, assert_equal, assert_almost_equal
     5
    76from aubio import cvec, filterbank, float_type
    87
     
    1312        f.set_mel_coeffs_slaney(16000)
    1413        a = f.get_coeffs()
    15         assert_equal(shape (a), (40, 512/2 + 1) )
     14        assert_equal(np.shape (a), (40, 512/2 + 1) )
    1615
    1716    def test_other_slaney(self):
    1817        f = filterbank(40, 512*2)
    1918        f.set_mel_coeffs_slaney(44100)
    20         _ = f.get_coeffs()
     19        self.assertIsInstance(f.get_coeffs(), np.ndarray)
    2120        #print "sum is", sum(sum(a))
    2221        for win_s in [256, 512, 1024, 2048, 4096]:
    2322            f = filterbank(40, win_s)
    2423            f.set_mel_coeffs_slaney(32000)
    25             _ = f.get_coeffs()
    2624            #print "sum is", sum(sum(a))
     25            self.assertIsInstance(f.get_coeffs(), np.ndarray)
    2726
    2827    def test_triangle_freqs_zeros(self):
    2928        f = filterbank(9, 1024)
    3029        freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000]
    31         freqs = array(freq_list, dtype = float_type)
     30        freqs = np.array(freq_list, dtype = float_type)
    3231        f.set_triangle_bands(freqs, 48000)
    33         _ = f.get_coeffs().T
    3432        assert_equal ( f(cvec(1024)), 0)
     33        self.assertIsInstance(f.get_coeffs(), np.ndarray)
    3534
    3635    def test_triangle_freqs_ones(self):
    3736        f = filterbank(9, 1024)
    3837        freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000]
    39         freqs = array(freq_list, dtype = float_type)
     38        freqs = np.array(freq_list, dtype = float_type)
    4039        f.set_triangle_bands(freqs, 48000)
    41         _ = f.get_coeffs().T
     40        self.assertIsInstance(f.get_coeffs(), np.ndarray)
    4241        spec = cvec(1024)
    4342        spec.norm[:] = 1
     
    4746
    4847if __name__ == '__main__':
    49     main()
     48    import nose2
     49    nose2.main()
Note: See TracChangeset for help on using the changeset viewer.