Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion tests/test_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_fft_buildup(self):
fourier.fft_vectorized(test_input).all())


def test_wrong_array_size(self):
def test_fft_wrong_array_size(self):
"""
Tests for correct input for the FFT_vectorized function.
Fails if the input is not a power of 2.
Expand All @@ -60,6 +60,16 @@ def test_wrong_array_size(self):
fourier.fft_vectorized(test_input)


def test_ifft_wrong_array_size(self):
"""
Tests for correct input for the ifft function.
Fails if the input is not a power of 2.
"""
test_input = np.random.random(30) + 1j * np.random.random(30)
with self.assertRaises(ValueError):
fourier.ifft(test_input)


def test_fft_smaller_shape(self):
"""
Test for FFT_vectorized function
Expand Down Expand Up @@ -137,5 +147,16 @@ def test_fft_shift_multi_axes(self):
test_output = [2, 3, 4, 5, 6, 7, 8, 9, 1]
self.assertSequenceEqual(fourier.fft_shift(test_input, [0, 0]).tolist(), test_output)


def test_fft_and_ifft(self):
"""
Test the fft and ifft
and expect the same outcome and input
"""
test_input = np.random.random(32) + 1j * np.random.random(32)
test_input = np.asarray(test_input)
self.assertEqual(test_input.all(), fourier.fft_vectorized(fourier.ifft(test_input)).all())


if __name__ == '__main__':
unittest.main()