Beispiel #1
0
def test_irfftn_execution(setup):
    raw = np.random.rand(10, 20, 30)
    t = tensor(raw, chunk_size=(10, 20, 30))

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

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

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

    # a bug in mkl version will cause the section below to fail
    if mkl_free_buffers is None:
        r = irfftn(t, s=(11, 21, 30), axes=(-1, -2, -3))
        res = r.execute().fetch()
        expected = np.fft.irfftn(raw, s=(11, 21, 30), axes=(-1, -2, -3))
        np.testing.assert_allclose(res, expected)
Beispiel #2
0
    def testIRFFTNExecution(self):
        raw = np.random.rand(10, 20, 30)
        t = tensor(raw, chunk_size=(10, 20, 30))

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

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

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

        # a bug in mkl version will cause the section below to fail
        if mkl_free_buffers is None:
            r = irfftn(t, s=(11, 21, 30), axes=(-1, -2, -3))
            res = self.executor.execute_tensor(r, concat=True)[0]
            expected = np.fft.irfftn(raw, s=(11, 21, 30), axes=(-1, -2, -3))
            np.testing.assert_allclose(res, expected)
Beispiel #3
0
    def testIRFFTNExecution(self):
        raw = np.random.rand(10, 20, 30)
        t = tensor(raw, chunk_size=(10, 20, 30))

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

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

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

        r = irfftn(t, s=(11, 21, 30), axes=(-1, -2, -3))
        res = self.executor.execute_tensor(r, concat=True)[0]
        expected = np.fft.irfftn(raw, s=(11, 21, 30), axes=(-1, -2, -3))
        np.testing.assert_allclose(res, expected)
Beispiel #4
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))
Beispiel #5
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)