def test_rfft2_execution(setup): raw = np.random.rand(10, 20, 30) t = tensor(raw, chunk_size=(8, 20, 30)) r = rfft2(t) res = r.execute().fetch() expected = np.fft.rfft2(raw) np.testing.assert_allclose(res, expected) r = rfft2(t, norm='ortho') res = r.execute().fetch() expected = np.fft.rfft2(raw, norm='ortho') np.testing.assert_allclose(res, expected) r = rfft2(t, s=(11, 12)) res = r.execute().fetch() expected = np.fft.rfft2(raw, s=(11, 12)) np.testing.assert_allclose(res, expected) r = rfft2(t, s=(11, 12), axes=(-1, -2)) res = r.execute().fetch() expected = np.fft.rfft2(raw, s=(11, 12), axes=(-1, -2)) np.testing.assert_allclose(res, expected)
def testRFFT2Execution(self): raw = np.random.rand(10, 20, 30) t = tensor(raw, chunk_size=(4, 20, 30)) r = rfft2(t) res = self.executor.execute_tensor(r, concat=True)[0] expected = np.fft.rfft2(raw) np.testing.assert_allclose(res, expected) r = rfft2(t, norm='ortho') res = self.executor.execute_tensor(r, concat=True)[0] expected = np.fft.rfft2(raw, norm='ortho') np.testing.assert_allclose(res, expected) r = rfft2(t, s=(11, 12)) res = self.executor.execute_tensor(r, concat=True)[0] expected = np.fft.rfft2(raw, s=(11, 12)) np.testing.assert_allclose(res, expected) r = rfft2(t, s=(11, 12), axes=(-1, -2)) res = self.executor.execute_tensor(r, concat=True)[0] expected = np.fft.rfft2(raw, s=(11, 12), axes=(-1, -2)) np.testing.assert_allclose(res, expected)
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))
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)