20
20
from importlib .resources import files
21
21
from pathlib import Path
22
22
23
+ import numpy as np
23
24
from numpy .typing import NDArray
24
25
import pytest
25
- import numpy as np
26
- import scipy .fft import fft
26
+ from scipy .fft import fft
27
27
28
- from CPAC .nuisance .bandpass import read_1D
29
- from CPAC .nuisance .bandpass import ideal_bandpass
28
+ from CPAC .nuisance .bandpass import ideal_bandpass , read_1D
30
29
31
30
RAW_ONE_D : Traversable = files ("CPAC" ).joinpath ("nuisance/tests/regressors.1D" )
32
31
@@ -51,12 +50,16 @@ def test_read_1D(start_line: int, tmp_path: Path) -> None:
51
50
assert len (header ) == 5 - start_line
52
51
53
52
54
- @pytest .mark .parametrize ("lowcut, highcut, in_freq, out_freq" , [
55
- (0.005 , 0.05 , 0.01 , 0.2 ),
56
- (0.01 , 0.1 , 0.02 , 0.15 ),
57
- (0.02 , 0.08 , 0.04 , 0.12 ),
58
- ])
53
+ @pytest .mark .parametrize (
54
+ "lowcut, highcut, in_freq, out_freq" ,
55
+ [
56
+ (0.005 , 0.05 , 0.01 , 0.2 ),
57
+ (0.01 , 0.1 , 0.02 , 0.15 ),
58
+ (0.02 , 0.08 , 0.04 , 0.12 ),
59
+ ],
60
+ )
59
61
def test_ideal_bandpass_with_various_cutoffs (lowcut , highcut , in_freq , out_freq ):
62
+ """Test the ideal bandpass filter with various cutoff frequencies."""
60
63
sample_period = 1.0
61
64
t = np .arange (512 ) * sample_period
62
65
signal = np .sin (2 * np .pi * in_freq * t ) + np .sin (2 * np .pi * out_freq * t )
@@ -71,4 +74,4 @@ def test_ideal_bandpass_with_various_cutoffs(lowcut, highcut, in_freq, out_freq)
71
74
idx_out = np .argmin (np .abs (freqs - out_freq ))
72
75
73
76
assert filt_fft [idx_in ] > 0.5 * orig_fft [idx_in ]
74
- assert filt_fft [idx_out ] < 0.1 * orig_fft [idx_out ]
77
+ assert filt_fft [idx_out ] < 0.1 * orig_fft [idx_out ]
0 commit comments