def test_epochs_vectorizer():
    'Test methods of EpochsVectorizer\n    '
    raw = io.read_raw_fif(raw_fname, preload=False)
    events = read_events(event_name)
    picks = pick_types(raw.info, meg=True, stim=False, ecg=False, eog=False, exclude='bads')
    picks = picks[1:13:3]
    with warnings.catch_warnings(record=True):
        epochs = Epochs(raw, events, event_id, tmin, tmax, picks=picks, baseline=(None, 0), preload=True)
    epochs_data = epochs.get_data()
    vector = EpochsVectorizer(epochs.info)
    y = epochs.events[:, (- 1)]
    X = vector.fit_transform(epochs_data, y)
    assert_true((X.shape[0] == epochs_data.shape[0]))
    assert_true((X.shape[1] == (epochs_data.shape[1] * epochs_data.shape[2])))
    assert_array_equal(vector.fit(epochs_data, y).transform(epochs_data), X)
    n_times = epochs_data.shape[2]
    assert_array_equal(epochs_data[0, 0, 0:n_times], X[0, 0:n_times])
    Xi = vector.inverse_transform(X, y)
    assert_true((Xi.shape[0] == epochs_data.shape[0]))
    assert_true((Xi.shape[1] == epochs_data.shape[1]))
    assert_array_equal(epochs_data[0, 0, 0:n_times], Xi[0, 0, 0:n_times])
    Xi = vector.inverse_transform(epochs_data[0], y)
    assert_true((Xi.shape[1] == epochs_data.shape[1]))
    assert_true((Xi.shape[2] == epochs_data.shape[2]))
    assert_raises(ValueError, vector.fit, epochs, y)
    assert_raises(ValueError, vector.transform, epochs, y)
Test methods of EpochsVectorizer
def test_epochs_vectorizer():
    '\n    '
    raw = io.read_raw_fif(raw_fname, preload=False)
    events = read_events(event_name)
    picks = pick_types(raw.info, meg=True, stim=False, ecg=False, eog=False, exclude='bads')
    picks = picks[1:13:3]
    with warnings.catch_warnings(record=True):
        epochs = Epochs(raw, events, event_id, tmin, tmax, picks=picks, baseline=(None, 0), preload=True)
    epochs_data = epochs.get_data()
    vector = EpochsVectorizer(epochs.info)
    y = epochs.events[:, (- 1)]
    X = vector.fit_transform(epochs_data, y)
    assert_true((X.shape[0] == epochs_data.shape[0]))
    assert_true((X.shape[1] == (epochs_data.shape[1] * epochs_data.shape[2])))
    assert_array_equal(vector.fit(epochs_data, y).transform(epochs_data), X)
    n_times = epochs_data.shape[2]
    assert_array_equal(epochs_data[0, 0, 0:n_times], X[0, 0:n_times])
    Xi = vector.inverse_transform(X, y)
    assert_true((Xi.shape[0] == epochs_data.shape[0]))
    assert_true((Xi.shape[1] == epochs_data.shape[1]))
    assert_array_equal(epochs_data[0, 0, 0:n_times], Xi[0, 0, 0:n_times])
    Xi = vector.inverse_transform(epochs_data[0], y)
    assert_true((Xi.shape[1] == epochs_data.shape[1]))
    assert_true((Xi.shape[2] == epochs_data.shape[2]))
    assert_raises(ValueError, vector.fit, epochs, y)
    assert_raises(ValueError, vector.transform, epochs, y)