def test_train_split(X, y, num_test = 0):
    '''
    Splits a full set of input and output data randomly into train and test sets. Keeps the input and output values
    connected.
    :param X: Numpy array with input data.
    :param y: Numpy array with output data.
    :param num_test: Number of samples to use for the test set. Set to 0 by default, which cause 1/5 of the full set to
        be split off for testing.
    :return: Four numpy arrays corresponding to the training input, training output, testing input, and testing output
        data.
    '''

    # Splits off 1/5 of data if no specific amount is given.
    if num_test == 0:
        num_test = 5 / y.shape[0]

    # Turns one-dimensional vector into array of shape (n, 1).
    if len(y.shape) == 1:
        y = y.reshape(len(y), 1)

    # Records the number of output features.
    output_features = y.shape[1]

    # Combines the input and output features so that the outputs can stay connected.
    all_vals = np.append(X, y, 1)

    # Randomly shuffles the samples.
    np.random.shuffle(all_vals)

    # Pulls out the test and train input and output features.
    teX, teY = all_vals[:num_test, :-output_features], all_vals[:num_test, -output_features:]
    trX, trY = all_vals[num_test:, :-output_features], all_vals[num_test:, -output_features:]

    return trX, trY, teX, teY
dataset/ETHPy150Open calvinschmdt/EasyTensorflow/easy_tensorflow/evolve_functions.py/test_train_split/swapped operands of `/`