History

python/tests/test_dct.py: add comments

Paul Brossier committed 9 years ago

Commit e7556a11 parent c96e6c01 file · +15 −9Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/tests/test_dct.py+15−9
@@ -5,10 +5,18 @@ import numpy as np · 4 unmodified lines
55 from numpy.testing import TestCase, assert_almost_equal
66 import aubio
77
8+precomputed_arange = [ 9.89949512, -6.44232273, 0., -0.67345482, 0.,
9+ -0.20090288, 0., -0.05070186]
10+
11+precomputed_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+
816 class 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)
1422
@@ -19,27 +27,23 @@ class aubio_dct(TestCase): · 4 unmodified lines
1927 >>> a_in = np.arange(8).astype('float32')
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')
4549 a_in[1] = 0
@@ -49,10 +53,12 @@ class aubio_dct(TestCase): · 3 unmodified lines
4953 assert_almost_equal(a_dct_reconstructed, a_in, decimal=6)
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:
5864 with self.assertRaises(RuntimeError):

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t