def test_fexpand(self): # test odd input res = np.random.rand(11) X = ft.freduce(np.fft.fft(res)) R = np.real(np.fft.ifft(ft.fexpand(X, 11))) self.assertTrue(np.all((res - R) < 1e-6)) # test even input res = np.random.rand(12) X = ft.freduce(np.fft.fft(res)) R = np.real(np.fft.ifft(ft.fexpand(X, 12))) self.assertTrue(np.all((res - R) < 1e-6)) # test with a 2 dimensional input along last dimension res = np.random.rand(2, 12) X = ft.freduce(np.fft.fft(res)) R = np.real(np.fft.ifft(ft.fexpand(X, 12))) self.assertTrue(np.all((res - R) < 1e-6)) # test with a 3 dimensional input along last dimension res = np.random.rand(3, 5, 12) X = ft.freduce(np.fft.fft(res)) R = np.real(np.fft.ifft(ft.fexpand(X, 12))) self.assertTrue(np.all((res - R) < 1e-6)) # test with 2 dimensional input along first dimension fs = np.transpose( mat.repmat(ft.fscale(500, 0.001, one_sided=True), 4, 1)) self.assertTrue(ft.fexpand(fs, 500, axis=0).shape == (500, 4))
def test_freduce(self): # test with 1D arrays fs = np.fft.fftfreq(5) self.assertTrue(np.all(ft.freduce(fs) == fs[:-2])) fs = np.fft.fftfreq(6) self.assertTrue(np.all(ft.freduce(fs) == fs[:-2])) # test 2D arrays along both dimensions fs = mat.repmat(ft.fscale(500, 0.001), 4, 1) self.assertTrue(ft.freduce(fs).shape == (4, 251)) self.assertTrue(ft.freduce(np.transpose(fs), axis=0).shape == (251, 4))
def test_freduce(self): fs = np.fft.fftfreq(5) self.assertTrue(np.all(ft.freduce(fs) == fs[:-2])) fs = np.fft.fftfreq(6) self.assertTrue(np.all(ft.freduce(fs) == fs[:-2]))