diff --git a/neurodsp/tests/test_filt_checks.py b/neurodsp/tests/test_filt_checks.py index 144431fb..32b5776e 100644 --- a/neurodsp/tests/test_filt_checks.py +++ b/neurodsp/tests/test_filt_checks.py @@ -46,8 +46,18 @@ def test_check_filter_definition(): def test_check_filter_properties(): filter_coefs = design_fir_filter(FS, 'bandpass', (8, 12)) - check_filter_properties(filter_coefs, 1, FS, 'bandpass', (8, 12)) - assert True + + passes = check_filter_properties(filter_coefs, 1, FS, 'bandpass', (8, 12)) + assert passes is True + + filter_coefs = design_fir_filter(FS, 'bandstop', (8, 12)) + passes = check_filter_properties(filter_coefs, 1, FS, 'bandpass', (8, 12)) + assert passes is False + + filter_coefs = design_fir_filter(FS, 'bandpass', (20, 21)) + passes = check_filter_properties(filter_coefs, 1, FS, 'bandpass', (8, 12)) + assert passes is False + def test_check_filter_length(): diff --git a/neurodsp/tests/test_filt_fir.py b/neurodsp/tests/test_filt_fir.py index e695457b..ddffdfd4 100644 --- a/neurodsp/tests/test_filt_fir.py +++ b/neurodsp/tests/test_filt_fir.py @@ -1,5 +1,6 @@ """Tests for FIR filters.""" +from pytest import raises import numpy as np from neurodsp.tests.settings import FS @@ -56,3 +57,7 @@ def test_compute_filter_length(): expected_filt_len = int(np.ceil(fs * n_cycles / f_lo)) + 1 filt_len = compute_filter_length(fs, 'bandpass', f_lo, f_hi, n_cycles=n_cycles, n_seconds=None) assert filt_len == expected_filt_len + + with raises(ValueError): + filt_len = compute_filter_length(fs, 'bandpass', f_lo, f_hi) + diff --git a/neurodsp/tests/test_filt_iir.py b/neurodsp/tests/test_filt_iir.py index bd37c149..4b209035 100644 --- a/neurodsp/tests/test_filt_iir.py +++ b/neurodsp/tests/test_filt_iir.py @@ -20,6 +20,9 @@ def test_filter_signal_iir_2d(tsig2d): assert out.shape == tsig2d.shape assert sum(~np.isnan(out[0, :])) > 0 + out, sos = filter_signal_iir(tsig2d, FS, 'bandpass', (8, 12), 3, return_filter=True) + assert np.shape(sos)[1] == 6 + def test_apply_iir_filter(tsig): out = apply_iir_filter(tsig, np.array([1, 1, 1, 1, 1, 1])) diff --git a/neurodsp/tests/test_filt_utils.py b/neurodsp/tests/test_filt_utils.py index 01897d89..c839a75d 100644 --- a/neurodsp/tests/test_filt_utils.py +++ b/neurodsp/tests/test_filt_utils.py @@ -1,5 +1,6 @@ """Tests for filter utilities.""" +from pytest import raises from neurodsp.tests.settings import FS from neurodsp.filt.utils import * @@ -19,6 +20,9 @@ def test_compute_frequency_response(): filter_coefs = design_fir_filter(FS, 'bandpass', (8, 12)) f_db, db = compute_frequency_response(filter_coefs, 1, FS) + with raises(ValueError): + f_db, db = compute_frequency_response(filter_coefs, None, FS) + def test_compute_pass_band(): assert compute_pass_band(FS, 'bandpass', (4, 8)) == 4.