示例#1
0
    def test_btss_split_on_neither_time_nor_index(self, time_series):

        with pytest.raises(ValueError):
            for element in blocking_time_series_split(time_series,
                                                      n_splits=5,
                                                      split_on='abc'):
                pass
示例#2
0
    def test_btss_too_many_folds(self, time_series):

        with pytest.raises(ValueError):
            for element in blocking_time_series_split(
                    time_series, n_splits=(len(time_series) + 1),
                    split_on='index'):
                pass
示例#3
0
    def test_btss_split_on_time_with_non_time_indexed_dataframe(
            self, non_time_index):
        # If the split_on is set to 'time' but index is not DateTime

        with pytest.raises(ValueError):
            for element in blocking_time_series_split(non_time_index,
                                                      n_splits=5,
                                                      split_on='time'):
                pass
示例#4
0
    def test_btss_timedelta_index(self, timedelta_index):
        record_count = []
        for fold_index in blocking_time_series_split(timedelta_index,
                                                     n_splits=5,
                                                     split_on='time'):
            record_count.append(len(fold_index))
        correct_record_count = []
        for fold_index in self._correct_btss_split_on_time_record_length(
                timedelta_index):
            correct_record_count.append(len(fold_index))

        assert all(
            [a == b for a, b in zip(correct_record_count, record_count)])
示例#5
0
    def test_btss_split_on_index(self, time_series):
        splits = 5
        split_length = len(time_series) // splits
        fold_length = split_length
        length_list = []

        for fold_index in blocking_time_series_split(time_series,
                                                     n_splits=splits,
                                                     split_on='index'):
            length_list.append(len(fold_index))
        for index_length in range(len(length_list) - 1):
            assert fold_length == length_list[index_length]
        last_fold_length = split_length + (len(time_series) % splits)

        assert last_fold_length == length_list[-1]