Test that ICA warns on certain input data conditions.
()
| 185 | |
| 186 | |
| 187 | def test_warnings(): |
| 188 | """Test that ICA warns on certain input data conditions.""" |
| 189 | raw = read_raw_fif(raw_fname).crop(0, 5).load_data() |
| 190 | events = read_events(event_name) |
| 191 | epochs = Epochs(raw, events=events, baseline=None, preload=True) |
| 192 | ica = ICA(n_components=2, max_iter=1, method="infomax", random_state=0) |
| 193 | |
| 194 | # not high-passed |
| 195 | with epochs.info._unlock(): |
| 196 | epochs.info["highpass"] = 0.0 |
| 197 | with pytest.warns(RuntimeWarning, match="should be high-pass filtered"): |
| 198 | ica.fit(epochs) |
| 199 | |
| 200 | # baselined |
| 201 | with epochs.info._unlock(): |
| 202 | epochs.info["highpass"] = 1.0 |
| 203 | epochs.baseline = (epochs.tmin, 0) |
| 204 | with pytest.warns(RuntimeWarning, match="epochs.*were baseline-corrected"): |
| 205 | ica.fit(epochs) |
| 206 | |
| 207 | # cleaning baseline-corrected data |
| 208 | with epochs.info._unlock(): |
| 209 | epochs.info["highpass"] = 1.0 |
| 210 | epochs.baseline = None |
| 211 | ica.fit(epochs) |
| 212 | |
| 213 | epochs.baseline = (epochs.tmin, 0) |
| 214 | with pytest.warns(RuntimeWarning, match="consider baseline-correcting.*again"): |
| 215 | ica.apply(epochs) |
| 216 | |
| 217 | |
| 218 | @pytest.mark.parametrize("n_components", (None, 0.9999, 8, 9, 10)) |
nothing calls this directly
no test coverage detected