import logging


def make_splits(args, dataset):
    """
    Make train-test splits in time.
    """
    total_hours = len(dataset['counts'])
    if args.truncate:
        total_hours = min(total_hours, args.truncate)

    # Dataset starts on a Saturday.
    assert dataset['start_date'][0].strftime('%A') == 'Saturday'

    # Ridership is minimum early Sunday morning.
    split_hour_of_week = 29

    # We train HMM on at least six years of historical data.
    min_hours = 6 * 365 * 24

    stride = 24 * 7

    result = list(range(min_hours + split_hour_of_week,
                        total_hours - args.forecast_hours,
                        stride))
    logging.info(f'Created {len(result)} test/train splits')
    assert result, 'truncated too short'
    return result