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