Changeset a95b386 for python/tests


Ignore:
Timestamp:
Nov 17, 2018, 4:38:29 PM (5 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:
ab8e838
Parents:
75f9fff (diff), 2eb52bd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into feature/pytest

Location:
python/tests
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_fft.py

    r75f9fff ra95b386  
    142142        assert_almost_equal ( r[1:], 0)
    143143
     144class aubio_fft_odd_sizes(TestCase):
     145
     146    def test_reconstruct_with_odd_size(self):
     147        win_s = 29
     148        self.recontruct(win_s, 'odd sizes not supported')
     149
     150    def test_reconstruct_with_radix15(self):
     151        win_s = 2 ** 4 * 15
     152        self.recontruct(win_s, 'radix 15 supported')
     153
     154    def test_reconstruct_with_radix5(self):
     155        win_s = 2 ** 4 * 5
     156        self.recontruct(win_s, 'radix 5 supported')
     157
     158    def test_reconstruct_with_radix3(self):
     159        win_s = 2 ** 4 * 3
     160        self.recontruct(win_s, 'radix 3 supported')
     161
     162    def recontruct(self, win_s, skipMessage):
     163        try:
     164            f = fft(win_s)
     165        except RuntimeError:
     166            self.skipTest(skipMessage)
     167        input_signal = fvec(win_s)
     168        input_signal[win_s//2] = 1
     169        c = f(input_signal)
     170        output_signal = f.rdo(c)
     171        assert_almost_equal(input_signal, output_signal)
     172
     173class aubio_fft_wrong_params(TestCase):
     174
    144175    def test_large_input_timegrain(self):
    145176        win_s = 1024
     
    169200        with self.assertRaises(ValueError):
    170201            f.rdo(s)
    171 
    172 class aubio_fft_wrong_params(TestCase):
    173202
    174203    def test_wrong_buf_size(self):
     
    176205        with self.assertRaises(ValueError):
    177206            fft(win_s)
    178 
    179     def test_buf_size_not_power_of_two(self):
    180         # when compiled with fftw3, aubio supports non power of two fft sizes
    181         win_s = 320
    182         try:
    183             with self.assertRaises(RuntimeError):
    184                 fft(win_s)
    185         except AssertionError:
    186             self.skipTest('creating aubio.fft with size %d did not fail' % win_s)
    187207
    188208    def test_buf_size_too_small(self):
  • python/tests/test_filterbank_mel.py

    r75f9fff ra95b386  
    110110
    111111
     112    def test_triangle_freqs_without_norm(self):
     113        """make sure set_triangle_bands works without """
     114        samplerate = 22050
     115        freq_list = fvec([0, 100, 1000, 10000])
     116        f = filterbank(len(freq_list) - 2, 1024)
     117        f.set_norm(0)
     118        f.set_triangle_bands(freq_list, samplerate)
     119        expected = f.get_coeffs()
     120        f.set_norm(1)
     121        f.set_triangle_bands(fvec(freq_list), samplerate)
     122        assert_almost_equal(f.get_coeffs().T,
     123                expected.T * 2. / (freq_list[2:] - freq_list[:-2]))
     124
     125    def test_triangle_freqs_wrong_norm(self):
     126        f = filterbank(10, 1024)
     127        with self.assertRaises(ValueError):
     128            f.set_norm(-1)
     129
     130    def test_triangle_freqs_with_power(self):
     131        f = filterbank(9, 1024)
     132        freqs = fvec([40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000,
     133            24000])
     134        f.set_power(2)
     135        f.set_triangle_bands(freqs, 48000)
     136        spec = cvec(1024)
     137        spec.norm[:] = .1
     138        expected = fvec([0.02070313, 0.02138672, 0.02127604, 0.02135417,
     139            0.02133301, 0.02133301, 0.02133311, 0.02133334, 0.02133345])
     140        expected /= 100.
     141        assert_almost_equal(f(spec), expected)
     142
     143    def test_mel_coeffs(self):
     144        f = filterbank(40, 1024)
     145        f.set_mel_coeffs(44100, 0, 44100 / 2)
     146
     147    def test_zero_fmax(self):
     148        f = filterbank(40, 1024)
     149        f.set_mel_coeffs(44100, 0, 0)
     150
     151    def test_wrong_mel_coeffs(self):
     152        f = filterbank(40, 1024)
     153        with self.assertRaises(ValueError):
     154            f.set_mel_coeffs_slaney(0)
     155        with self.assertRaises(ValueError):
     156            f.set_mel_coeffs(44100, 0, -44100 / 2)
     157        with self.assertRaises(ValueError):
     158            f.set_mel_coeffs(44100, -0.1, 44100 / 2)
     159        with self.assertRaises(ValueError):
     160            f.set_mel_coeffs(-44100, 0.1, 44100 / 2)
     161        with self.assertRaises(ValueError):
     162            f.set_mel_coeffs_htk(-1, 0, 0)
     163
     164    def test_mel_coeffs_htk(self):
     165        f = filterbank(40, 1024)
     166        f.set_mel_coeffs_htk(44100, 0, 44100 / 2)
     167
     168
    112169if __name__ == '__main__':
    113170    from unittest import main
Note: See TracChangeset for help on using the changeset viewer.