Skip to content

Commit 092f970

Browse files
committed
split out tests for add_* methods
1 parent 2a66519 commit 092f970

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

fooof/tests/objs/test_fit.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,36 +226,54 @@ def test_fooof_load():
226226
for meta_dat in OBJ_DESC['meta_data']:
227227
assert getattr(tfm, meta_dat) is not None
228228

229-
def test_adds():
230-
"""Tests methods that add data to FOOOF objects.
229+
def test_add_data():
230+
"""Tests method to add data to FOOOF objects."""
231231

232-
Checks: add_data, add_settings, add_results.
233-
"""
234-
235-
# Note: uses it's own tfm, to not add stuff to the global one
232+
# This test uses it's own FOOOF object, to not add stuff to the global one
236233
tfm = get_tfm()
237234

238235
# Test adding data
239236
freqs, pows = np.array([1, 2, 3]), np.array([10, 10, 10])
240237
tfm.add_data(freqs, pows)
238+
239+
assert tfm.has_data
241240
assert np.all(tfm.freqs == freqs)
242241
assert np.all(tfm.power_spectrum == np.log10(pows))
243242

243+
def test_add_settings():
244+
"""Tests method to add settings to FOOOF objects."""
245+
246+
# This test uses it's own FOOOF object, to not add stuff to the global one
247+
tfm = get_tfm()
248+
244249
# Test adding settings
245250
fooof_settings = FOOOFSettings([1, 4], 6, 0, 2, 'fixed')
246251
tfm.add_settings(fooof_settings)
247252
for setting in OBJ_DESC['settings']:
248253
assert getattr(tfm, setting) == getattr(fooof_settings, setting)
249254

255+
def test_add_meta_data():
256+
"""Tests method to add meta data to FOOOF objects."""
257+
258+
# This test uses it's own FOOOF object, to not add stuff to the global one
259+
tfm = get_tfm()
260+
250261
# Test adding meta data
251262
fooof_meta_data = FOOOFMetaData([3, 40], 0.5)
252263
tfm.add_meta_data(fooof_meta_data)
253264
for meta_dat in OBJ_DESC['meta_data']:
254265
assert getattr(tfm, meta_dat) == getattr(fooof_meta_data, meta_dat)
255266

267+
def test_add_results():
268+
"""Tests method to add results to FOOOF objects."""
269+
270+
# This test uses it's own FOOOF object, to not add stuff to the global one
271+
tfm = get_tfm()
272+
256273
# Test adding results
257274
fooof_results = FOOOFResults([1, 1], [10, 0.5, 0.5], 0.95, 0.02, [10, 0.5, 0.25])
258275
tfm.add_results(fooof_results)
276+
assert tfm.has_model
259277
for setting in OBJ_DESC['results']:
260278
assert getattr(tfm, setting) == getattr(fooof_results, setting.strip('_'))
261279

0 commit comments

Comments
 (0)