<commit_before>import numpy as np


def pad_targets(xy):
    """
    Pad the targets to be 1hot.
    :param xy: A tuple containing the x and y matrices.
    :return: The 1hot coded dataset.
    """
    x, y = xy
    classes = np.max(y) + 1
    tmp_data_y = np.zeros((x.shape[0], classes))
    for i, dp in zip(range(len(y)), y):
        r = np.zeros(classes)
        r[dp] = 1
        tmp_data_y[i] = r
    y = tmp_data_y
    return x, y


def cut_off_dataset(xy, cut_off, rng):
    x, y = xy
    n = x.shape[0]
    keep = n - (n % cut_off)
    idx = rng.choice(n, size=keep, replace=False)
    return x[idx, :], y[idx]


def create_semi_supervised(xy, n_labeled, rng):
    """
    Divide the dataset into labeled and unlabeled data.
    :param xy: The training set of the mnist data.
    :param n_labeled: The number of labeled data points.
    :param rng: NumPy random generator.
    :return: labeled x, labeled y, unlabeled x, unlabeled y.
    """
    x, y = xy
    n_classes = np.max(y) + 1

    def _split_by_class(x, y, n_c):
        x, y = x.T, y.T
        result_x = [0] * n_c
        result_y = [0] * n_c<commit_msg>fixed int conversion in data_helper<commit_after>import numpy as np


def pad_targets(xy):
    """
    Pad the targets to be 1hot.
    :param xy: A tuple containing the x and y matrices.
    :return: The 1hot coded dataset.
    """
    x, y = xy
    classes = np.max(y) + 1
    tmp_data_y = np.zeros((x.shape[0], classes))
    for i, dp in zip(range(len(y)), y):
        r = np.zeros(classes)
        r[dp] = 1
        tmp_data_y[i] = r
    y = tmp_data_y
    return x, y


def cut_off_dataset(xy, cut_off, rng):
    x, y = xy
    n = x.shape[0]
    keep = n - (n % cut_off)
    idx = rng.choice(n, size=keep, replace=False)
    return x[idx, :], y[idx]


def create_semi_supervised(xy, n_labeled, rng):
    """
    Divide the dataset into labeled and unlabeled data.
    :param xy: The training set of the mnist data.
    :param n_labeled: The number of labeled data points.
    :param rng: NumPy random generator.
    :return: labeled x, labeled y, unlabeled x, unlabeled y.
    """
    x, y = xy
    n_classes = int(np.max(y) + 1)

    def _split_by_class(x, y, n_c):
        x, y = x.T, y.T
        result_x = [0] * n_c
        result_y = [0] * n_c
{'fraction_non_alphanumeric': 0.12384716732542819, 'fraction_numerical': 0.007905138339920948, 'mean_word_length': 2.335285505124451, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '939429', 'n_tokens_mistral': 902, 'n_tokens_neox': 865, 'n_words': 275}