1212from fooof .core .items import OBJ_DESC
1313from fooof .core .errors import FitError
1414from fooof .core .utils import group_three
15- from fooof .sim import gen_power_spectrum
15+ from fooof .sim import gen_freqs , gen_power_spectrum
1616from fooof .data import FOOOFSettings , FOOOFMetaData , FOOOFResults
1717from fooof .core .errors import DataError , NoDataError , InconsistentDataError
1818
@@ -364,7 +364,7 @@ def raise_runtime_error(*args, **kwargs):
364364 assert np .all (np .isnan (getattr (tfm , result )))
365365
366366def test_fooof_debug ():
367- """Test FOOOF fit failure in debug mode."""
367+ """Test FOOOF in debug mode, including with fit failures ."""
368368
369369 tfm = FOOOF (verbose = False )
370370 tfm ._maxfev = 5
@@ -374,3 +374,22 @@ def test_fooof_debug():
374374
375375 with raises (FitError ):
376376 tfm .fit (* gen_power_spectrum ([3 , 50 ], [50 , 2 ], [10 , 0.5 , 2 , 20 , 0.3 , 4 ]))
377+
378+ def test_fooof_check_data ():
379+ """Test FOOOF in with check data mode turned off, including with NaN data."""
380+
381+ tfm = FOOOF (verbose = False )
382+
383+ tfm .set_check_data_mode (False )
384+ assert tfm ._check_data is False
385+
386+ # Add data, with check data turned off
387+ # In check data mode, adding data with NaN should run
388+ freqs = gen_freqs ([3 , 50 ], 0.5 )
389+ powers = np .ones_like (freqs ) * np .nan
390+ tfm .add_data (freqs , powers )
391+ assert tfm .has_data
392+
393+ # Model fitting should execute, but return a null model fit, given the NaNs, without failing
394+ tfm .fit ()
395+ assert not fm .has_model
0 commit comments