コード例 #1
0
def dst_2d_ref(x, **kwargs):
    """Calculate reference values for testing dst2."""
    x = np.array(x, copy=True)
    for row in range(x.shape[0]):
        x[row, :] = dst(x[row, :], **kwargs)
    for col in range(x.shape[1]):
        x[:, col] = dst(x[:, col], **kwargs)
    return x
コード例 #2
0
ファイル: test_real_transforms.py プロジェクト: xtchenn/scipy
def test_dst4_definition_ortho(rdt, mdata_x):
    # Test orthornomal mode.
    dec = dec_map[(dst, rdt, 4)]
    x = np.array(mdata_x, dtype=rdt)
    dt = np.result_type(np.float32, rdt)
    y = dst(x, norm='ortho', type=4)
    y2 = naive_dst4(x, norm='ortho')
    assert_equal(y.dtype, dt)
    assert_array_almost_equal(y, y2, decimal=dec)
コード例 #3
0
ファイル: test_real_transforms.py プロジェクト: xtchenn/scipy
def test_dst1_definition_ortho(rdt, mdata_x):
    # Test orthornomal mode.
    dec = dec_map[(dst, rdt, 1)]
    x = np.array(mdata_x, dtype=rdt)
    dt = np.result_type(np.float32, rdt)
    y = dst(x, norm='ortho', type=1)
    y2 = naive_dst1(x, norm='ortho')
    assert_equal(y.dtype, dt)
    assert_allclose(y, y2, rtol=0., atol=np.max(y2)*10**(-dec))
コード例 #4
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 = dst(x, norm='ortho', type=4)
         y2 = naive_dst4(x, norm='ortho')
         assert_equal(y.dtype, dt)
         assert_array_almost_equal(y, y2, decimal=self.dec)
コード例 #5
0
 def test_definition(self):
     for i in FFTWDATA_SIZES:
         xr, yr, dt = fftw_dst_ref(self.type, i, self.rdt)
         y = dst(xr, 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)
コード例 #6
0
ファイル: test_real_transforms.py プロジェクト: xtchenn/scipy
def test_definition(fftwdata_size, rdt, type):
    xr, yr, dt = fftw_dst_ref(type, fftwdata_size, rdt)
    y = dst(xr, type=type)
    dec = dec_map[(dst, rdt, type)]
    assert_equal(y.dtype, dt)
    assert_allclose(y, yr, rtol=0., atol=np.max(yr)*10**(-dec))
コード例 #7
0
 def test_dst_complex(self):
     y = dst(np.arange(5)*1j)
     x = 1j*dst(np.arange(5))
     assert_array_almost_equal(x, y)
コード例 #8
0
 def test_dst_complex64(self):
     y = dst(np.arange(5, dtype=np.complex64)*1j)
     x = 1j*dst(np.arange(5))
     assert_array_almost_equal(x, y)