# GNU GPLv3, see LICENSE
from unittest import TestCase
from ..fft import *
class TestFFT(TestCase):
def test_dft(self):
self.assertEqual(dft([0]), [0+0j])
self.assertEqual(dft([1]), [1+0j])
self.assertEqual(dft([2]), [2+0j])
all(self.assertAlmostEqual(a, b) for (a, b) in zip(dft([3, 1]), [4+0j, 2+0j]))
all(self.assertAlmostEqual(a, b) for (a, b) in zip(dft([3, 1, 4]), [8+0j, 0.5+2.59807621j, 0.5-2.59807621j]))
all(self.assertAlmostEqual(a, b) for (a, b) in zip(dft([3, 1, 4, 1]), [9+0j, -1+0j, 5+0j, -1+0j]))
all(self.assertAlmostEqual(a, b) for (a, b) in zip(
dft([3, 1, 4, 1, 5]),
[14+0j, 0.80901699+2.04087031j, -0.30901699+5.20431056j, -0.30901699-5.20431056j, 0.80901699-2.04087031j]
))