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