from typing import Union


def train_test_split(*arrays, test_size: Union[int, float] = 0.3, verbose: bool = False):
    """
    Split train set & test set by time order.

    Args:
        *arrays: Tuple of arrays with same length, i.e. (X, y) or (X1, X2, y).
        test_size: Test set size, if is float (< 1) then represents ratio; if is integer then represents length.
        verbose: If True, print split output shape.

    Returns: (train_set: List, test_set: List).

    """
    sample_size = arrays[0].shape[0]
    assert all(sample_size == array.shape[0] for array in arrays), "Size mismatch between arrays"

    if isinstance(test_size, int):
        split = sample_size - test_size
    else:
        split = int(sample_size * (1 - test_size))
    train_set, test_set = [], []
    for array in arrays:
        train_set.append(array[:split])
        test_set.append(array[split:])
    if verbose:
        print(f"Train Set Shape: {[array.shape for array in train_set]}")
        print(f"Test Set Shape: {[array.shape for array in test_set]}")
    return train_set, test_set