diff --git a/phys2denoise/tests/conftest.py b/phys2denoise/tests/conftest.py new file mode 100644 index 0000000..1022b3e --- /dev/null +++ b/phys2denoise/tests/conftest.py @@ -0,0 +1,14 @@ +import numpy as np +import pytest + + +@pytest.fixture(scope="module") +def fake_phys(): + f = 0.3 + fs = 62.5 # sampling rate + t = 300 + samples = np.arange(t * fs) / fs + noise = np.random.normal(0, 0.5, len(samples)) + fake_phys = 10 * np.sin(2 * np.pi * f * samples) + noise + return fake_phys + diff --git a/phys2denoise/tests/test_rvt.py b/phys2denoise/tests/test_rvt.py index 95b7c9b..7923ac6 100644 --- a/phys2denoise/tests/test_rvt.py +++ b/phys2denoise/tests/test_rvt.py @@ -1,30 +1,19 @@ import peakdet -import numpy as np -import pytest from phys2denoise.metrics.chest_belt import rvt -@pytest.fixture -def fake_phys(): - f = 0.3 - fs = 62.5 # sampling rate - t = 300 - samples = np.arange(t * fs) / fs - noise = np.random.normal(0, 0.5, len(samples)) - fake_phys = 10 * np.sin(2 * np.pi * f * samples) + noise +def test_peakdet(fake_phys): phys = peakdet.Physio(fake_phys, fs=62.5) phys = peakdet.operations.filter_physio(phys, cutoffs=3, method="lowpass") - return phys - - -def test_peakdet(fake_phys): - phys = peakdet.operations.peakfind_physio(fake_phys) + phys = peakdet.operations.peakfind_physio(phys) assert phys.troughs is not None assert phys.peaks is not None def test_rvt(fake_phys): - phys = peakdet.operations.peakfind_physio(fake_phys) + phys = peakdet.Physio(fake_phys, fs=62.5) + phys = peakdet.operations.filter_physio(phys, cutoffs=3, method="lowpass") + phys = peakdet.operations.peakfind_physio(phys) r = rvt(phys.data, phys.peaks, phys.troughs, samplerate=phys.fs) assert r is not None assert len(r) == 18750