Skip to content

Commit a10cb48

Browse files
committed
add tresults & update check_dep
1 parent a1e76ed commit a10cb48

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

fooof/core/modutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,6 @@ def wrapped_func(*args, **kwargs):
177177
if not dep:
178178
raise ImportError("Optional FOOOF dependency " + name + \
179179
" is required for this functionality.")
180-
func(*args, **kwargs)
180+
return func(*args, **kwargs)
181181
return wrapped_func
182182
return wrap

fooof/tests/conftest.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from fooof.core.modutils import safe_import
1010

11-
from fooof.tests.tutils import get_tfm, get_tfg, get_tbands
11+
from fooof.tests.tutils import get_tfm, get_tfg, get_tbands, get_tresults
1212
from fooof.tests.settings import BASE_TEST_FILE_PATH, TEST_DATA_PATH, TEST_REPORTS_PATH
1313

1414
plt = safe_import('.pyplot', 'matplotlib')
@@ -46,7 +46,16 @@ def tfg():
4646
def tbands():
4747
yield get_tbands()
4848

49+
@pytest.fixture(scope='session')
50+
def tresults():
51+
yield get_tresults()
52+
4953
@pytest.fixture(scope='session')
5054
def skip_if_no_mpl():
5155
if not safe_import('matplotlib'):
5256
pytest.skip('Matplotlib not available: skipping test.')
57+
58+
@pytest.fixture(scope='session')
59+
def skip_if_no_pandas():
60+
if not safe_import('pandas'):
61+
pytest.skip('Pandas not available: skipping test.')

fooof/tests/tutils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
from functools import wraps
44

5+
import numpy as np
6+
57
from fooof.bands import Bands
8+
from fooof.data import FOOOFResults
69
from fooof.objs import FOOOF, FOOOFGroup
710
from fooof.core.modutils import safe_import
811
from fooof.sim.params import param_sampler
@@ -43,6 +46,14 @@ def get_tbands():
4346

4447
return Bands({'theta' : (4, 8), 'alpha' : (8, 12), 'beta' : (13, 30)})
4548

49+
def get_tresults():
50+
"""Get a FOOOFResults objet, for testing."""
51+
52+
return FOOOFResults(aperiodic_params=np.array([1.0, 1.00]),
53+
peak_params=np.array([[10.0, 1.25, 2.0], [20.0, 1.0, 3.0]]),
54+
r_squared=0.97, error=0.01,
55+
gaussian_params=np.array([[10.0, 1.25, 1.0], [20.0, 1.0, 1.5]]))
56+
4657
def default_group_params():
4758
"""Create default parameters for generating a test group of power spectra."""
4859

0 commit comments

Comments
 (0)