예제 #1
0
def idct_2d_ref(x, **kwargs):
    """Calculate reference values for testing idct2."""
    x = np.array(x, copy=True)
    for row in range(x.shape[0]):
        x[row, :] = idct(x[row, :], **kwargs)
    for col in range(x.shape[1]):
        x[:, col] = idct(x[:, col], **kwargs)
    return x
예제 #2
0
 def test_definition(self):
     for i in FFTWDATA_SIZES:
         xr, yr, dt = fftw_dct_ref(self.type, i, self.rdt)
         x = idct(yr, type=self.type)
         assert_equal(x.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(x / np.max(x), xr / np.max(x), decimal=self.dec,
                 err_msg="Size %d failed" % i)
예제 #3
0
def test_idct_definition(fftwdata_size, rdt, type):
    xr, yr, dt = fftw_dct_ref(type, fftwdata_size, rdt)
    x = idct(yr, type=type)
    dec = dec_map[(idct, rdt, type)]
    assert_equal(x.dtype, dt)
    assert_allclose(x, xr, rtol=0., atol=np.max(xr)*10**(-dec))
예제 #4
0
 def test_idct_complex(self):
     y = idct(np.arange(5)*1j)
     x = 1j*idct(np.arange(5))
     assert_array_almost_equal(x, y)