MCPcopy
hub / github.com/mne-tools/mne-python / test_fit_methods

Function test_fit_methods

mne/preprocessing/tests/test_ica.py:1210–1245  ·  view source on GitHub ↗

Test fit_params for ICA.

(method, tmp_path)

Source from the content-addressed store, hash-verified

1208
1209@pytest.mark.parametrize("method", ["fastica", "picard", "infomax"])
1210def test_fit_methods(method, tmp_path):
1211 """Test fit_params for ICA."""
1212 _skip_check_picard(method)
1213 fit_params = {}
1214 # test no side effects
1215 ICA(fit_params=fit_params, method=method)
1216 assert fit_params == {}
1217
1218 # Test I/O roundtrip.
1219 # Only picard and infomax support the "extended" keyword, so limit the
1220 # tests to those.
1221 if method in ["picard", "infomax"]:
1222 output_fname = tmp_path / "test_ica-ica.fif"
1223
1224 raw = read_raw_fif(raw_fname).crop(0.5, stop).load_data()
1225 n_components = 3
1226 max_iter = 1
1227 fit_params = dict(extended=True)
1228 ica = ICA(
1229 fit_params=fit_params,
1230 n_components=n_components,
1231 max_iter=max_iter,
1232 method=method,
1233 )
1234 fit_params_after_instantiation = ica.fit_params
1235
1236 if method == "infomax":
1237 ica.fit(raw)
1238 else:
1239 with pytest.warns(UserWarning, match="did not converge"):
1240 ica.fit(raw)
1241
1242 ica.save(output_fname)
1243 ica = read_ica(output_fname)
1244
1245 assert ica.fit_params == fit_params_after_instantiation
1246
1247
1248@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 8

fitMethod · 0.95
saveMethod · 0.95
read_raw_fifFunction · 0.90
read_icaFunction · 0.90
_skip_check_picardFunction · 0.85
ICAFunction · 0.70
load_dataMethod · 0.45
cropMethod · 0.45

Tested by

no test coverage detected