Example #1
0
    def testStandardFFT(self):
        t = ones((10, 20, 30), chunk_size=(3, 20, 30))

        t1 = fft.fft(t)
        self.assertEqual(t1.shape, (10, 20, 30))
        self.assertEqual(calc_shape(t1), t1.shape)
        t1.tiles()
        self.assertEqual(t1.shape, tuple(sum(ns) for ns in t1.nsplits))
        self.assertEqual(calc_shape(t1.chunks[0]), t1.chunks[0].shape)

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

        t1 = fft.ifft(t)
        self.assertEqual(t1.shape, (10, 20, 30))
        self.assertEqual(calc_shape(t1), t1.shape)
        t1.tiles()
        self.assertEqual(t1.shape, tuple(sum(ns) for ns in t1.nsplits))
        self.assertEqual(calc_shape(t1.chunks[0]), t1.chunks[0].shape)

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

        t1 = fft.fft2(t, s=(23, 21))
        self.assertEqual(calc_shape(t1), t1.shape)
        self.assertEqual(t1.shape, (10, 23, 21))
        t1.tiles()
        self.assertEqual(t1.shape, tuple(sum(ns) for ns in t1.nsplits))
        self.assertEqual(calc_shape(t1.chunks[0]), t1.chunks[0].shape)

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

        t1 = fft.ifft2(t, s=(11, 9), axes=(1, 2))
        self.assertEqual(calc_shape(t1), t1.shape)
        self.assertEqual(t1.shape, (10, 11, 9))
        t1.tiles()
        self.assertEqual(t1.shape, tuple(sum(ns) for ns in t1.nsplits))
        self.assertEqual(calc_shape(t1.chunks[0]), t1.chunks[0].shape)

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

        t1 = fft.fftn(t, s=(11, 9), axes=(1, 2))
        self.assertEqual(calc_shape(t1), t1.shape)
        self.assertEqual(t1.shape, (10, 11, 9))
        t1.tiles()
        self.assertEqual(t1.shape, tuple(sum(ns) for ns in t1.nsplits))
        self.assertEqual(calc_shape(t1.chunks[0]), t1.chunks[0].shape)

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

        t1 = fft.ifftn(t, s=(11, 9), axes=(1, 2))
        self.assertEqual(calc_shape(t1), t1.shape)
        self.assertEqual(t1.shape, (10, 11, 9))
        t1.tiles()
        self.assertEqual(t1.shape, tuple(sum(ns) for ns in t1.nsplits))
        self.assertEqual(calc_shape(t1.chunks[0]), t1.chunks[0].shape)
Example #2
0
def test_ifftn_execution(setup):
    raw = np.random.rand(10, 20, 30)
    t = tensor(raw, chunk_size=(10, 20, 30))

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

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

    r = ifftn(t, s=(11, 12, 5))
    res = r.execute().fetch()
    expected = np.fft.ifftn(raw, s=(11, 12, 5))
    np.testing.assert_allclose(res, expected)

    r = ifftn(t, s=(11, 12, 5), axes=(-1, -2, -3))
    res = r.execute().fetch()
    expected = np.fft.ifftn(raw, s=(11, 12, 5), axes=(-1, -2, -3))
    np.testing.assert_allclose(res, expected)

    raw = np.random.rand(10, 20, 30)
    t = tensor(raw, chunk_size=(6, 8, 14))

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

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

    r = ifftn(t, s=(11, 12, 5))
    res = r.execute().fetch()
    expected = np.fft.ifftn(raw, s=(11, 12, 5))
    np.testing.assert_allclose(res, expected)

    r = ifftn(t, s=(11, 12, 5), axes=(-1, -2, -3))
    res = r.execute().fetch()
    expected = np.fft.ifftn(raw, s=(11, 12, 5), axes=(-1, -2, -3))
    np.testing.assert_allclose(res, expected)
Example #3
0
    def testIFFTNExecution(self):
        raw = np.random.rand(10, 20, 30)
        t = tensor(raw, chunk_size=(10, 20, 30))

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

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

        r = ifftn(t, s=(11, 12, 5))
        res = self.executor.execute_tensor(r, concat=True)[0]
        expected = np.fft.ifftn(raw, s=(11, 12, 5))
        np.testing.assert_allclose(res, expected)

        r = ifftn(t, s=(11, 12, 5), axes=(-1, -2, -3))
        res = self.executor.execute_tensor(r, concat=True)[0]
        expected = np.fft.ifftn(raw, s=(11, 12, 5), axes=(-1, -2, -3))
        np.testing.assert_allclose(res, expected)

        raw = np.random.rand(10, 20, 30)
        t = tensor(raw, chunk_size=(3, 4, 7))

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

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

        r = ifftn(t, s=(11, 12, 5))
        res = self.executor.execute_tensor(r, concat=True)[0]
        expected = np.fft.ifftn(raw, s=(11, 12, 5))
        np.testing.assert_allclose(res, expected)

        r = ifftn(t, s=(11, 12, 5), axes=(-1, -2, -3))
        res = self.executor.execute_tensor(r, concat=True)[0]
        expected = np.fft.ifftn(raw, s=(11, 12, 5), axes=(-1, -2, -3))
        np.testing.assert_allclose(res, expected)
Example #4
0
def test_standard_fft():
    t = ones((10, 20, 30), chunk_size=(3, 20, 30))

    t1 = fft(t)
    assert t1.shape == (10, 20, 30)
    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 = ifft(t)
    assert t1.shape == (10, 20, 30)
    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 = fft2(t, s=(23, 21))
    assert t1.shape == (10, 23, 21)
    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 = ifft2(t, s=(11, 9), axes=(1, 2))
    assert t1.shape == (10, 11, 9)
    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 = fftn(t, s=(11, 9), axes=(1, 2))
    assert t1.shape == (10, 11, 9)
    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 = ifftn(t, s=(11, 9), axes=(1, 2))
    assert t1.shape == (10, 11, 9)
    t1 = tile(t1)
    assert t1.shape == tuple(sum(ns) for ns in t1.nsplits)