Skip to content
Snippets Groups Projects
Commit f0a7458a authored by Simon Bjurek's avatar Simon Bjurek
Browse files

Removed test that took too long for pipeline and added docstring for the fft function.

parent 30719d0b
No related branches found
No related tags found
1 merge request!462Add SFG generator for DIF FFT
Pipeline #155547 passed
This commit is part of merge request !462. Comments created here will be created in the context of that merge request.
......@@ -378,6 +378,18 @@ def direct_form_2_iir(
def radix_2_dif_fft(points: int) -> SFG:
"""Generates a radix-2 decimation-in-frequency FFT structure.
Parameters
----------
points : int
Number of points for the FFT, needs to be a positive power of 2.
Returns
-------
SFG
Signal Flow Graph
"""
if points < 0:
raise ValueError("Points must be positive number.")
if points & (points - 1) != 0:
......
......@@ -358,28 +358,6 @@ def test_radix_2_dif_fft_256_points_sinus_input():
assert np.isclose(a, b)
def test_radix_2_dif_fft_512_points_sinus_input_half_frequency():
POINTS = 512
sfg = radix_2_dif_fft(points=POINTS)
assert len(sfg.inputs) == POINTS
assert len(sfg.outputs) == POINTS
n = np.linspace(0, 2 * np.pi, POINTS)
waveform = np.sin(0.5 * n)
input_samples = [Constant(waveform[i]) for i in range(POINTS)]
sim = Simulation(sfg, input_samples)
sim.run_for(1)
exp_res = np.fft.fft(waveform)
res = sim.results
for i in range(POINTS):
a = res[str(i)]
b = exp_res[i]
assert np.isclose(a, b)
def test_radix_2_dif_fft_negative_number_of_points():
POINTS = -8
with pytest.raises(ValueError, match="Points must be positive number."):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment