Example #1
0
def test_cutoff_window_splitter(y, cutoffs, fh, window_length):
    """Test CutoffSplitter."""
    if _inputs_are_supported([cutoffs, fh, window_length]):
        cv = CutoffSplitter(cutoffs, fh=fh, window_length=window_length)
        train_windows, test_windows, cutoffs, n_splits = _check_cv(cv, y)
        np.testing.assert_array_equal(cutoffs, cv.get_cutoffs(y))
    else:
        match = "Unsupported combination of types"
        with pytest.raises(TypeError, match=match):
            CutoffSplitter(cutoffs, fh=fh, window_length=window_length)
def test_cutoff_window_splitter(y, cutoffs, fh, window_length):
    """Test CutoffSplitter."""
    cv = CutoffSplitter(cutoffs, fh=fh, window_length=window_length)
    if _cutoffs_fh_window_length_types_are_supported(
            cutoffs=cutoffs,
            fh=ForecastingHorizon(fh),
            window_length=window_length):
        train_windows, test_windows, cutoffs, n_splits = _check_cv(cv, y)
        np.testing.assert_array_equal(cutoffs, cv.get_cutoffs(y))
    else:
        match = "Unsupported combination of types"
        with pytest.raises(TypeError, match=match):
            _check_cv(cv, y)
Example #3
0
def test_manual_window_split(y, cutoffs, fh, window_length):
    # initiate rolling window cv iterator
    cv = CutoffSplitter(cutoffs, fh=fh, window_length=window_length)

    # generate and keep splits
    training_windows, test_windows, n_splits, _ = generate_and_check_windows(
        y, cv)

    # check cutoffs
    np.testing.assert_array_equal(cutoffs, cv.get_cutoffs(y))

    # check training windows
    n_incomplete_windows = get_n_incomplete_windows(training_windows,
                                                    window_length)
    check_windows_dimensions(training_windows, n_incomplete_windows,
                             window_length)

    # check test windows
    check_test_windows(test_windows, fh, cutoffs)
Example #4
0
def test_cutoff_window_splitter(y, cutoffs, fh, window_length):
    """Test CutoffSplitter."""
    cv = CutoffSplitter(cutoffs, fh=fh, window_length=window_length)
    train_windows, test_windows, cutoffs, n_splits = _check_cv(cv, y)
    np.testing.assert_array_equal(cutoffs, cv.get_cutoffs(y))