예제 #1
0
def test_rfft_execution(setup):
    raw = np.random.rand(10, 20, 30)
    t = tensor(raw, chunk_size=(8, 8, 30))

    r = rfft(t)
    res = r.execute().fetch()
    expected = np.fft.rfft(raw)
    np.testing.assert_allclose(res, expected)

    r = rfft(t, norm='ortho')
    res = r.execute().fetch()
    expected = np.fft.rfft(raw, norm='ortho')
    np.testing.assert_allclose(res, expected)

    r = rfft(t, n=11)
    res = r.execute().fetch()
    expected = np.fft.rfft(raw, n=11)
    np.testing.assert_allclose(res, expected)
예제 #2
0
    def testRFFTExecution(self):
        raw = np.random.rand(10, 20, 30)
        t = tensor(raw, chunk_size=(4, 4, 30))

        r = rfft(t)
        res = self.executor.execute_tensor(r, concat=True)[0]
        expected = np.fft.rfft(raw)
        np.testing.assert_allclose(res, expected)

        r = rfft(t, norm='ortho')
        res = self.executor.execute_tensor(r, concat=True)[0]
        expected = np.fft.rfft(raw, norm='ortho')
        np.testing.assert_allclose(res, expected)

        r = rfft(t, n=11)
        res = self.executor.execute_tensor(r, concat=True)[0]
        expected = np.fft.rfft(raw, n=11)
        np.testing.assert_allclose(res, expected)
예제 #3
0
    def testRealFFT(self):
        t = ones((10, 20, 30), chunk_size=(3, 20, 30))

        t1 = rfft(t)
        self.assertEqual(t1.shape, np.fft.rfft(np.ones(t.shape)).shape)
        t1.tiles()
        self.assertEqual(t1.shape, tuple(sum(ns) for ns in t1.nsplits))

        t = ones((10, 20, 30), chunk_size=(3, 20, 30))

        t1 = irfft(t)
        self.assertEqual(t1.shape, np.fft.irfft(np.ones(t.shape)).shape)
        t1.tiles()
        self.assertEqual(t1.shape, tuple(sum(ns) for ns in t1.nsplits))

        t = ones((10, 20, 30), chunk_size=(3, 20, 30))

        t1 = rfft2(t, s=(23, 21))
        self.assertEqual(t1.shape,
                         np.fft.rfft2(np.ones(t.shape), s=(23, 21)).shape)
        t1.tiles()
        self.assertEqual(t1.shape, tuple(sum(ns) for ns in t1.nsplits))

        t = ones((10, 20, 30), chunk_size=(3, 20, 30))

        t1 = irfft2(t, s=(11, 9), axes=(1, 2))
        self.assertEqual(
            t1.shape,
            np.fft.irfft2(np.ones(t.shape), s=(11, 9), axes=(1, 2)).shape)
        t1.tiles()
        self.assertEqual(t1.shape, tuple(sum(ns) for ns in t1.nsplits))

        t = ones((10, 20, 30), chunk_size=(3, 20, 30))

        t1 = rfftn(t, s=(11, 30), axes=(1, 2))
        self.assertEqual(
            t1.shape,
            np.fft.rfftn(np.ones(t.shape), s=(11, 30), axes=(1, 2)).shape)
        t1.tiles()
        self.assertEqual(t1.shape, tuple(sum(ns) for ns in t1.nsplits))

        t = ones((10, 20, 30), chunk_size=(3, 20, 30))

        t1 = irfftn(t, s=(11, 9), axes=(1, 2))
        self.assertEqual(
            t1.shape,
            np.fft.irfftn(np.ones(t.shape), s=(11, 9), axes=(1, 2)).shape)
        t1.tiles()
        self.assertEqual(t1.shape, tuple(sum(ns) for ns in t1.nsplits))
예제 #4
0
def test_real_fft():
    t = ones((10, 20, 30), chunk_size=(3, 20, 30))

    t1 = rfft(t)
    assert t1.shape == np.fft.rfft(np.ones(t.shape)).shape
    t1 = tile(t1)
    assert t1.shape == tuple(sum(ns) for ns in t1.nsplits)

    t = ones((10, 20, 30), chunk_size=(3, 20, 30))

    t1 = irfft(t)
    assert t1.shape == np.fft.irfft(np.ones(t.shape)).shape
    t1 = tile(t1)
    assert t1.shape == tuple(sum(ns) for ns in t1.nsplits)

    t = ones((10, 20, 30), chunk_size=(3, 20, 30))

    t1 = rfft2(t, s=(23, 21))
    assert t1.shape == np.fft.rfft2(np.ones(t.shape), s=(23, 21)).shape
    t1 = tile(t1)
    assert t1.shape == tuple(sum(ns) for ns in t1.nsplits)

    t = ones((10, 20, 30), chunk_size=(3, 20, 30))

    t1 = irfft2(t, s=(11, 9), axes=(1, 2))
    assert t1.shape == np.fft.irfft2(np.ones(t.shape), s=(11, 9),
                                     axes=(1, 2)).shape
    t1 = tile(t1)
    assert t1.shape == tuple(sum(ns) for ns in t1.nsplits)

    t = ones((10, 20, 30), chunk_size=(3, 20, 30))

    t1 = rfftn(t, s=(11, 30), axes=(1, 2))
    assert t1.shape == np.fft.rfftn(np.ones(t.shape), s=(11, 30),
                                    axes=(1, 2)).shape
    t1 = tile(t1)
    assert t1.shape == tuple(sum(ns) for ns in t1.nsplits)

    t = ones((10, 20, 30), chunk_size=(3, 20, 30))

    t1 = irfftn(t, s=(11, 9), axes=(1, 2))
    assert t1.shape == np.fft.irfftn(np.ones(t.shape), s=(11, 9),
                                     axes=(1, 2)).shape
    t1 = tile(t1)
    assert t1.shape == tuple(sum(ns) for ns in t1.nsplits)