def test_complex_dft_close_to_np_fft(self): x = self.build_sinus() re, im = dft(x) np_dft = np.fft.fft(x) self.assertTrue(np.allclose(re, np.real(np_dft[:len(np_dft) // 2]))) self.assertTrue(np.allclose(im, np.imag(np_dft[:len(np_dft) // 2])))
def test_dft_i_dft_equal_1(self): x = self.build_sinus() re, im = dft(x) x_restored = i_dft(re, im) npt.assert_almost_equal(x, x_restored, decimal=2)
def test_re_im_length_2(self): re, im = dft(self.x_2) self.assertEqual(re.size, 5) self.assertEqual(im.size, 5)
def test_dft_equal_1(self): re, im = dft(self.x_3) expected = np.full((16, ), 32) npt.assert_almost_equal(re, expected)
def test_re_im_length_1(self): re, im = dft(self.x_1) self.assertEqual(re.size, 4) self.assertEqual(im.size, 4)