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