<commit_before>import operator

def _compare_keys(element1, element2, key, compare_func, *args):
    if key in element1 and key in element2:
        if not compare_func(element1[key], element2[key], *args):
            return False
    elif key in element1 or key in element2:
        return False

    return True


def _compare_vector(arr1, arr2):
    """
    Compares two vectors (python lists) for approximate equality.

    Each array contains floats or strings convertible to floats

    This function returns True if both arrays are of the same length
    and each value is approximately equal.
    """

    length = len(arr1)
    if len(arr2) != length:
        return False

    for i in range(length):
        element_1 = float(arr1(i))
        element_2 = float(arr2(i))


        diff = abs(abs(element_1) - abs(element_2))
        rel = diff / min(abs(element_1), abs(element_2))
        
        # For a basis set, a relatively coarse comparison
        # should be acceptible
        if rel > 1.0e-10:
            return False

    return True


def _compare_matrix(mat1, mat2):
    """
    Compares two matrices (nested python lists) for approximate equality.

    Each matrix contains floats or strings convertible to floats

    This function returns True if both matrices are of the same dimensions
    and each value is approximately equal.
    """

    length = len(mat1)
    if len(mat2) != length:
        return False

    for i in range(length):
        if _compare_vector(mat1(i), mat2(i)) == False:
            return False

    return True
         
<commit_msg>Fix errors in curate comparison functions<commit_after>import operator

def _compare_keys(element1, element2, key, compare_func, *args):
    if key in element1 and key in element2:
        if not compare_func(element1[key], element2[key], *args):
            return False
    elif key in element1 or key in element2:
        return False

    return True


def _compare_vector(arr1, arr2):
    """
    Compares two vectors (python lists) for approximate equality.

    Each array contains floats or strings convertible to floats

    This function returns True if both arrays are of the same length
    and each value is approximately equal.
    """

    length = len(arr1)
    if len(arr2) != length:
        return False

    for i in range(length):
        element_1 = float(arr1[i])
        element_2 = float(arr2[i])


        diff = abs(abs(element_1) - abs(element_2))
        if diff != 0.0:
            rel = diff / min(abs(element_1), abs(element_2))
        
            # For a basis set, a relatively coarse comparison
            # should be acceptible
            if rel > 1.0e-10:
                return False

    return True


def _compare_matrix(mat1, mat2):
    """
    Compares two matrices (nested python lists) for approximate equality.

    Each matrix contains floats or strings convertible to floats

    This function returns True if both matrices are of the same dimensions
    and each value is approximately equal.
    """

    length = len(mat1)
    if len(mat2) != length:
        return False

    for i in range(length):
        if _compare_vector(mat1[i], mat2[i]) == False:
            return False

    return True
         

{'fraction_non_alphanumeric': 0.07318573185731857, 'fraction_numerical': 0.019065190651906518, 'mean_word_length': 2.406282722513089, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6161263', 'n_tokens_mistral': 932, 'n_tokens_neox': 885, 'n_words': 350}