Changeset e7556a1 for python/tests


Ignore:
Timestamp:
Sep 16, 2017, 11:46:30 PM (7 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/pydocstrings, feature/timestretch, fix/ffmpeg5, master
Children:
b99e2a5
Parents:
c96e6c0
Message:

python/tests/test_dct.py: add comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_dct.py

    rc96e6c0 re7556a1  
    66import aubio
    77
     8precomputed_arange = [ 9.89949512, -6.44232273,  0., -0.67345482, 0.,
     9        -0.20090288, 0., -0.05070186]
     10
     11precomputed_some_ones = [ 4.28539848,  0.2469689,  -0.14625292, -0.58121818,
     12        -0.83483052, -0.75921834, -0.35168475,  0.24087936,
     13        0.78539824, 1.06532764,  0.97632152,  0.57164496, 0.03688532,
     14        -0.39446154, -0.54619485, -0.37771079]
     15
    816class aubio_dct(TestCase):
    917
    1018    def test_init(self):
    11         """ check aubio.dct() can be created """
     19        """ test that aubio.dct() is created with expected size """
    1220        a_dct = aubio.dct()
    1321        self.assertEqual(a_dct.size, 1024)
     
    2028        >>> precomputed = dct(a_in, norm='ortho')
    2129        """
    22         precomputed = [ 9.89949512, -6.44232273,  0., -0.67345482, 0.,
    23                 -0.20090288, 0., -0.05070186]
     30        N = len(precomputed_arange)
    2431        a_dct = aubio.dct(8)
    2532        a_in = np.arange(8).astype('float32')
    26         a_expected = aubio.fvec(precomputed)
     33        a_expected = aubio.fvec(precomputed_arange)
    2734        assert_almost_equal(a_dct(a_in), a_expected, decimal=6)
    2835
    2936    def test_some_ones(self):
    3037        """ test that dct(somevector) is computed correctly """
    31         precomputed = [ 4.28539848,  0.2469689,  -0.14625292, -0.58121818,
    32                 -0.83483052, -0.75921834, -0.35168475,  0.24087936,
    33                 0.78539824, 1.06532764,  0.97632152,  0.57164496, 0.03688532,
    34                 -0.39446154, -0.54619485, -0.37771079]
    3538        a_dct = aubio.dct(16)
    3639        a_in = np.ones(16).astype('float32')
    3740        a_in[1] = 0
    3841        a_in[3] = np.pi
    39         a_expected = aubio.fvec(precomputed)
     42        a_expected = aubio.fvec(precomputed_some_ones)
    4043        assert_almost_equal(a_dct(a_in), a_expected, decimal=7)
    4144
    4245    def test_reconstruction(self):
     46        """ test that some_ones vector can be recontructed """
    4347        a_dct = aubio.dct(16)
    4448        a_in = np.ones(16).astype('float32')
     
    5054
    5155    def test_negative_size(self):
     56        """ test that creation fails with a negative size """
    5257        with self.assertRaises(ValueError):
    5358            aubio.dct(-1)
    5459
    5560    def test_wrong_size(self):
     61        """ test that creation fails with a non power-of-two size """
    5662        # supports for non 2** fft sizes only when compiled with fftw3
    5763        try:
Note: See TracChangeset for help on using the changeset viewer.