Test fit_params for ICA.
(method, tmp_path)
| 1208 | |
| 1209 | @pytest.mark.parametrize("method", ["fastica", "picard", "infomax"]) |
| 1210 | def 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( |
nothing calls this directly
no test coverage detected