Skip to content

Commit ad9eef9

Browse files
committed
update test for add_data, for clearing results or not
1 parent b5a0386 commit ad9eef9

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

fooof/tests/objs/test_fit.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,28 @@ def test_add_data():
232232
# This test uses it's own FOOOF object, to not add stuff to the global one
233233
tfm = get_tfm()
234234

235-
# Test adding data
235+
# Test data for adding
236236
freqs, pows = np.array([1, 2, 3]), np.array([10, 10, 10])
237-
tfm.add_data(freqs, pows)
238237

238+
# Test adding data
239+
tfm.add_data(freqs, pows)
239240
assert tfm.has_data
240241
assert np.all(tfm.freqs == freqs)
241242
assert np.all(tfm.power_spectrum == np.log10(pows))
242243

244+
# Test that prior data does not get cleared, when requesting not to clear
245+
tfm._reset_data_results(True, True, True)
246+
tfm.add_results(FOOOFResults([1, 1], [10, 0.5, 0.5], 0.95, 0.02, [10, 0.5, 0.25]))
247+
tfm.add_data(freqs, pows, clear_results=False)
248+
assert tfm.has_data
249+
assert tfm.has_model
250+
251+
# Test that prior data does get cleared, when requesting not to clear
252+
tfm._reset_data_results(True, True, True)
253+
tfm.add_data(freqs, pows, clear_results=True)
254+
assert tfm.has_data
255+
assert not tfm.has_model
256+
243257
def test_add_settings():
244258
"""Tests method to add settings to FOOOF objects."""
245259

0 commit comments

Comments
 (0)