Пример #1
0
 def test_definition_ortho(self):
     # Test orthornomal mode.
     for i in range(len(X)):
         x = np.array(X[i], dtype=self.rdt)
         dt = np.result_type(np.float32, self.rdt)
         y = dct(x, norm='ortho', type=2)
         xi = dct(y, norm="ortho", type=3)
         assert_equal(xi.dtype, dt)
         assert_array_almost_equal(xi, x, decimal=self.dec)
Пример #2
0
    def test_axis(self):
        nt = 2
        for i in [7, 8, 9, 16, 32, 64]:
            x = np.random.randn(nt, i)
            y = dct(x, type=self.type)
            for j in range(nt):
                assert_array_almost_equal(y[j],
                                          dct(x[j], type=self.type),
                                          decimal=self.dec)

            x = x.T
            y = dct(x, axis=0, type=self.type)
            for j in range(nt):
                assert_array_almost_equal(y[:, j],
                                          dct(x[:, j], type=self.type),
                                          decimal=self.dec)
Пример #3
0
    def test_definition_matlab(self):
        # Test correspondance with matlab (orthornomal mode).
        for i in range(len(X)):
            dt = np.result_type(np.float32, self.rdt)
            x = np.array(X[i], dtype=dt)

            yr = Y[i]
            y = dct(x, norm="ortho", type=2)
            assert_equal(y.dtype, dt)
            assert_array_almost_equal(y, yr, decimal=self.dec)
Пример #4
0
 def test_definition(self):
     for i in FFTWDATA_SIZES:
         x, yr, dt = fftw_dct_ref(self.type, i, self.rdt)
         y = dct(x, type=self.type)
         assert_equal(y.dtype, dt)
         # XXX: we divide by np.max(y) because the tests fail otherwise. We
         # should really use something like assert_array_approx_equal. The
         # difference is due to fftw using a better algorithm w.r.t error
         # propagation compared to the ones from fftpack.
         assert_array_almost_equal(y / np.max(y),
                                   yr / np.max(y),
                                   decimal=self.dec,
                                   err_msg="Size %d failed" % i)
Пример #5
0
 def test_dct_complex(self):
     y = dct(np.arange(5) * 1j)
     x = 1j * dct(np.arange(5))
     assert_array_almost_equal(x, y)
Пример #6
0
 def test_dct_complex64(self):
     y = dct(1j * np.arange(5, dtype=np.complex64))
     x = 1j * dct(np.arange(5))
     assert_array_almost_equal(x, y)