Changeset 67024ff for python/tests


Ignore:
Timestamp:
Nov 2, 2018, 8:34:17 PM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master
Children:
8607a74
Parents:
5af36fa
Message:

[tests] capture warnings from filterbank_mel, improve coverage

Location:
python/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_filterbank_mel.py

    r5af36fa r67024ff  
    33import numpy as np
    44from numpy.testing import TestCase, assert_equal, assert_almost_equal
     5from _tools import assert_warns
    56
    67from aubio import cvec, filterbank, float_type
     
    2930        freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000]
    3031        freqs = np.array(freq_list, dtype = float_type)
    31         f.set_triangle_bands(freqs, 48000)
     32        with assert_warns(UserWarning):
     33            f.set_triangle_bands(freqs, 48000)
    3234        assert_equal ( f(cvec(1024)), 0)
    3335        self.assertIsInstance(f.get_coeffs(), np.ndarray)
     
    3739        freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000]
    3840        freqs = np.array(freq_list, dtype = float_type)
    39         f.set_triangle_bands(freqs, 48000)
     41        with assert_warns(UserWarning):
     42            f.set_triangle_bands(freqs, 48000)
    4043        self.assertIsInstance(f.get_coeffs(), np.ndarray)
    4144        spec = cvec(1024)
     
    4548                    0.02133301, 0.02133301, 0.02133311, 0.02133334, 0.02133345])
    4649
     50    def test_triangle_freqs_normal(self):
     51        """ create a filter with set_triangle_bands, normal mode """
     52        f = filterbank(3, 1024)
     53        freq_list = [100, 1000, 10000, 15000, 20000]
     54        freqs = np.array(freq_list, dtype = float_type)
     55        f.set_triangle_bands(freqs, 44100)
     56
     57    def test_triangle_freqs_too_long(self):
     58        """ create a filter with freq_list too long """
     59        f = filterbank(2, 1024)
     60        freq_list = [100, 1000, 10000, 15000, 20000]
     61        freqs = np.array(freq_list, dtype = float_type)
     62        with assert_warns(UserWarning):
     63            f.set_triangle_bands(freqs, 44100)
     64
     65    def test_triangle_freqs_too_short(self):
     66        """ create a filter with freq_list too short """
     67        f = filterbank(4, 1024)
     68        freq_list = [100, 1000, 10000, 15000, 20000]
     69        freqs = np.array(freq_list, dtype = float_type)
     70        with assert_warns(UserWarning):
     71            f.set_triangle_bands(freqs, 44100)
     72
     73    def test_above_nyquist(self):
     74        """ create a filter with freq_list too short """
     75        f = filterbank(3, 1024)
     76        freq_list = [100, 1000, 10000, 15000, 23000]
     77        freqs = np.array(freq_list, dtype = float_type)
     78        with assert_warns(UserWarning):
     79            f.set_triangle_bands(freqs, 44100)
     80
    4781if __name__ == '__main__':
    4882    from unittest import main
  • python/tests/test_source.py

    r5af36fa r67024ff  
    7070        if 'f_' in soundfile and samplerate == 0:
    7171            import re
    72             f = re.compile('.*_\([0:9]*f\)_.*')
     72            f = re.compile(r'.*_\([0:9]*f\)_.*')
    7373            match_f = re.findall('([0-9]*)f_', soundfile)
    7474            if len(match_f) == 1:
Note: See TracChangeset for help on using the changeset viewer.