<commit_before>import numpy as np


def dict_np_2_dict_list(input_dict):
    """
    Convert a dict of numpy array to a dict of list
    """
    if type(input_dict) is dict:
        for name in list(input_dict.keys()):
            input_dict.update({name: input_dict[name].tolist()})
        return input_dict
    else:
        return input_dict.tolist()


def dict_list_2_dict_np(input_dict):
    """
    Convert a dict of list to a dict of numpy array
    """
    if type(input_dict) is dict:
        for name in list(input_dict.keys()):
            input_dict.update({name: np.array(input_dict[name])})
        return input_dict
    else:
        return np.array(input_dict)<commit_msg>prevent copy issue in dict tools<commit_after># ---------------------------------------------------------#
# Utilities to handle dictionary
# ---------------------------------------------------------#
import copy
import numpy as np


def dict_np_to_dict_list(input_dict):
    """
    Convert a dict of numpy array to a dict of list
    """
    input_dict = copy.copy(input_dict)
    if type(input_dict) is dict:
        for name in list(input_dict.keys()):
            input_dict.update({name: input_dict[name].tolist()})
        return input_dict
    else:
        return input_dict.tolist()


def dict_list_to_dict_np(input_dict):
    """
    Convert a dict of list to a dict of numpy array
    """
    input_dict = copy.copy(input_dict)
    if type(input_dict) is dict:
        for name in list(input_dict.keys()):
            input_dict.update({name: np.array(input_dict[name])})
        return input_dict
    else:
        return np.array(input_dict)


def list_to_dict(names, arrs):
    """
    Matching a list of array with names
    """
    if type(arrs) is list:
        final_dict = {}
        for name, arr in zip(names, arrs):
            final_dict.update({name: arr})
        return final_dict
    elif type(arrs) is np.ndarray and len(names) == 1:
        return {names[0]: arrs}
    else:
        return arrs
{'fraction_non_alphanumeric': 0.15201192250372578, 'fraction_numerical': 0.001987083954297069, 'mean_word_length': 2.127329192546584, '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': '5296586', 'n_tokens_mistral': 615, 'n_tokens_neox': 607, 'n_words': 173}