def test_filterestimator():
    'Test methods of FilterEstimator\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]
    epochs = Epochs(raw, events, event_id, tmin, tmax, picks=picks, baseline=(None, 0), preload=True)
    epochs_data = epochs.get_data()
    filt = FilterEstimator(epochs.info, l_freq=1, h_freq=40)
    y = epochs.events[:, (- 1)]
    with warnings.catch_warnings(record=True):
        X = filt.fit_transform(epochs_data, y)
        assert_true((X.shape == epochs_data.shape))
        assert_array_equal(filt.fit(epochs_data, y).transform(epochs_data), X)
    filt = FilterEstimator(epochs.info, l_freq=0, h_freq=40)
    y = epochs.events[:, (- 1)]
    with warnings.catch_warnings(record=True):
        X = filt.fit_transform(epochs_data, y)
    filt = FilterEstimator(epochs.info, l_freq=1, h_freq=1)
    y = epochs.events[:, (- 1)]
    with warnings.catch_warnings(record=True):
        assert_raises(ValueError, filt.fit_transform, epochs_data, y)
    filt = FilterEstimator(epochs.info, l_freq=1, h_freq=None)
    with warnings.catch_warnings(record=True):
        X = filt.fit_transform(epochs_data, y)
    assert_raises(ValueError, filt.fit, epochs, y)
    assert_raises(ValueError, filt.transform, epochs, y)
Test methods of FilterEstimator
def test_filterestimator():
    '\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]
    epochs = Epochs(raw, events, event_id, tmin, tmax, picks=picks, baseline=(None, 0), preload=True)
    epochs_data = epochs.get_data()
    filt = FilterEstimator(epochs.info, l_freq=1, h_freq=40)
    y = epochs.events[:, (- 1)]
    with warnings.catch_warnings(record=True):
        X = filt.fit_transform(epochs_data, y)
        assert_true((X.shape == epochs_data.shape))
        assert_array_equal(filt.fit(epochs_data, y).transform(epochs_data), X)
    filt = FilterEstimator(epochs.info, l_freq=0, h_freq=40)
    y = epochs.events[:, (- 1)]
    with warnings.catch_warnings(record=True):
        X = filt.fit_transform(epochs_data, y)
    filt = FilterEstimator(epochs.info, l_freq=1, h_freq=1)
    y = epochs.events[:, (- 1)]
    with warnings.catch_warnings(record=True):
        assert_raises(ValueError, filt.fit_transform, epochs_data, y)
    filt = FilterEstimator(epochs.info, l_freq=1, h_freq=None)
    with warnings.catch_warnings(record=True):
        X = filt.fit_transform(epochs_data, y)
    assert_raises(ValueError, filt.fit, epochs, y)
    assert_raises(ValueError, filt.transform, epochs, y)