import random


def get_training_test_data_split(data_dictionary, split_ratio):
    """
    Given a data dictionary of structure {label : images list},
    return a training list and a test list. Each list element is made up of
    (image, label) tuple. Split ratio determines ratio of data samples that are
    put into training set. Remaining items are put into test set.
    :param data_dictionary:
    :param split_ratio:
    :return:
    """

    training_data = []
    test_data = []

    for label, images in data_dictionary.items():

        random.shuffle(images)

        training_size = int(len(images) * split_ratio)
        data = [(image, label) for image in images]

        training_data.extend(data[:training_size])
        test_data.extend(data[training_size:])

    return training_data, test_data