python/tests/test_dct.py: reduce precision for dct ramp
[aubio.git] / python / tests / test_dct.py
index bba5a62..0c990f9 100755 (executable)
@@ -24,28 +24,28 @@ class aubio_dct(TestCase):
         """ test that dct(arange(8)) is computed correctly
 
         >>> from scipy.fftpack import dct
-        >>> a_in = np.arange(8).astype('float32')
+        >>> a_in = np.arange(8).astype(aubio.float_type)
         >>> precomputed = dct(a_in, norm='ortho')
         """
         N = len(precomputed_arange)
         a_dct = aubio.dct(8)
-        a_in = np.arange(8).astype('float32')
+        a_in = np.arange(8).astype(aubio.float_type)
         a_expected = aubio.fvec(precomputed_arange)
-        assert_almost_equal(a_dct(a_in), a_expected, decimal=6)
+        assert_almost_equal(a_dct(a_in), a_expected, decimal=5)
 
     def test_some_ones(self):
         """ test that dct(somevector) is computed correctly """
         a_dct = aubio.dct(16)
-        a_in = np.ones(16).astype('float32')
+        a_in = np.ones(16).astype(aubio.float_type)
         a_in[1] = 0
         a_in[3] = np.pi
         a_expected = aubio.fvec(precomputed_some_ones)
-        assert_almost_equal(a_dct(a_in), a_expected, decimal=7)
+        assert_almost_equal(a_dct(a_in), a_expected, decimal=6)
 
     def test_reconstruction(self):
         """ test that some_ones vector can be recontructed """
         a_dct = aubio.dct(16)
-        a_in = np.ones(16).astype('float32')
+        a_in = np.ones(16).astype(aubio.float_type)
         a_in[1] = 0
         a_in[3] = np.pi
         a_dct_in = a_dct(a_in)
@@ -60,8 +60,9 @@ class aubio_dct(TestCase):
     def test_wrong_size(self):
         """ test that creation fails with a non power-of-two size """
         # supports for non 2** fft sizes only when compiled with fftw3
+        size = 13
         try:
             with self.assertRaises(RuntimeError):
-                aubio.dct(13)
+                aubio.dct(size)
         except AssertionError:
-            self.skipTest('creating aubio.dct with size %d did not fail' % win_s)
+            self.skipTest('creating aubio.dct with size %d did not fail' % size)