1212import pkg_resources as pkg
1313
1414from fooof import FOOOF
15+ from fooof .data import FOOOFSettings , FOOOFResults
1516from fooof .synth import gen_power_spectrum
1617from fooof .core .utils import group_three , get_obj_desc
1718
@@ -105,6 +106,44 @@ def test_fooof_load():
105106 tfm .load (file_name_res , file_path )
106107 assert tfm
107108
109+ def test_adds ():
110+ """Tests methods that add data to FOOOF objects.
111+
112+ Checks: add_data, add_settings, add_results.
113+ """
114+
115+ # Note: uses it's own tfm, to not add stuff to the global one
116+ tfm = get_tfm ()
117+
118+ # Test adding data
119+ freqs , pows = np .array ([1 , 2 , 3 ]), np .array ([10 , 10 , 10 ])
120+ tfm .add_data (freqs , pows )
121+ assert np .all (tfm .freqs == freqs )
122+ assert np .all (tfm .power_spectrum == np .log10 (pows ))
123+
124+ # Test adding settings
125+ fooof_settings = FOOOFSettings ([1 , 4 ], 6 , 0 , 2 , 'fixed' )
126+ tfm .add_settings (fooof_settings )
127+ for setting in get_obj_desc ()['settings' ]:
128+ assert getattr (tfm , setting ) == getattr (fooof_settings , setting )
129+
130+ # Test adding results
131+ fooof_results = FOOOFResults ([1 , 1 ], [10 , 0.5 , 0.5 ], 0.95 , 0.02 , [10 , 0.5 , 0.25 ])
132+ tfm .add_results (fooof_results )
133+ for setting in get_obj_desc ()['results' ]:
134+ assert getattr (tfm , setting ) == getattr (fooof_results , setting .strip ('_' ))
135+
136+ def test_gets (tfm ):
137+ """Tests methods that return FOOOF data objects.
138+
139+ Checks: get_settings, get_results
140+ """
141+
142+ settings = tfm .get_settings ()
143+ assert isinstance (settings , FOOOFSettings )
144+ results = tfm .get_results ()
145+ assert isinstance (results , FOOOFResults )
146+
108147def test_copy ():
109148 """Test copy FOOOF method."""
110149
@@ -122,12 +161,6 @@ def test_fooof_prints_get(tfm):
122161 tfm .print_results ()
123162 tfm .print_report_issue ()
124163
125- results = tfm .get_results ()
126- assert results
127-
128- settings = tfm .get_settings ()
129- assert settings
130-
131164@plot_test
132165def test_fooof_plot (tfm , skip_if_no_mpl ):
133166 """Check the alias to plot FOOOF."""
0 commit comments