|
17 | 17 |
|
18 | 18 | from sklearn.decomposition import PCA
|
19 | 19 | from sklearn.kernel_ridge import KernelRidge
|
| 20 | +from sklearn.pipeline import make_pipeline |
| 21 | +from sklearn.preprocessing import StandardScaler |
20 | 22 | from sklearn.utils.estimator_checks import parametrize_with_checks
|
21 | 23 |
|
22 |
| -from mne import Epochs, create_info, io, pick_types, read_events |
| 24 | +from mne import Epochs, EpochsArray, create_info, io, pick_types, read_events |
23 | 25 | from mne.decoding import (
|
24 | 26 | FilterEstimator,
|
| 27 | + LinearModel, |
25 | 28 | PSDEstimator,
|
26 | 29 | Scaler,
|
27 | 30 | TemporalFilter,
|
@@ -218,9 +221,16 @@ def test_vectorizer():
|
218 | 221 | assert_equal(vect.fit_transform(data[1:]).shape, (149, 108))
|
219 | 222 |
|
220 | 223 | # check if raised errors are working correctly
|
221 |
| - vect.fit(np.random.rand(105, 12, 3)) |
222 |
| - pytest.raises(ValueError, vect.transform, np.random.rand(105, 12, 3, 1)) |
223 |
| - pytest.raises(ValueError, vect.inverse_transform, np.random.rand(102, 12, 12)) |
| 224 | + X = np.random.default_rng(0).standard_normal((105, 12, 3)) |
| 225 | + y = np.arange(X.shape[0]) % 2 |
| 226 | + pytest.raises(ValueError, vect.transform, X[..., np.newaxis]) |
| 227 | + pytest.raises(ValueError, vect.inverse_transform, X[:, :-1]) |
| 228 | + |
| 229 | + # And that pipelines work properly |
| 230 | + X_arr = EpochsArray(X, create_info(12, 1000.0, "eeg")) |
| 231 | + vect.fit(X_arr) |
| 232 | + clf = make_pipeline(Vectorizer(), StandardScaler(), LinearModel()) |
| 233 | + clf.fit(X_arr, y) |
224 | 234 |
|
225 | 235 |
|
226 | 236 | def test_unsupervised_spatial_filter():
|
|
0 commit comments