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