<commit_before>class Mapping(object):
    """
    class to map numbers from one range to another range
    """

    def _init__(self):
        pass

    @staticmethod
    def linlin(value, a, b, c, d):
        """
            maps value \in [a,b] linearly to the corresponding value \in [c, d]
            e.g. linlin(0.3,0,1,10,20) = 13
        """
        if a == b:
            if value == a and c == d:
                return c
            return None

        return ((c + d) + (d - c) * ((2 * value - (a + b)) / float(b - a))) / 2.0
<commit_msg>add some mappings<commit_after>import math


class Mapping(object):
    """
    class to map numbers from one range to another range
    """

    def _init__(self):
        pass

    @staticmethod
    def linlin(value, in_min, in_max, out_min, out_max):
        """
        maps value \in [in_min,in_max] linearly to the corresponding value \in [out_min, out_max]
        (extrapolating if needed)
        e.g. linlin(0.3,0,1,10,20) = 13
            
        :param value: value to be mapped 
        :param in_min: input range minimum
        :param in_max: input range maximum
        :param out_min: what input range minimum is mapped to
        :param out_max: what input range maximum is mapped to
        :return: linear mapping from value in input range to value in output range (extrapolating if needed)
         
         example: linlin(0.2, 0, 1, 10, 20) = 13
        """
        if in_min == in_max:
            if value == in_min and out_min == out_max:
                return out_min
            return None

        return ((out_min + out_max) + (out_max - out_min) * (
                (2 * value - (in_min + in_max)) / float(in_max - in_min))) / 2.0

    @staticmethod
    def linexp(value, in_min, in_max, out_min, out_max):
        """
        maps value \in linear range [in_min,in_max] corresponding value \in exponential range [out_min, out_max]
        (extrapolating if needed)

        :param value: value to be mapped 
        :param in_min: input range minimum
        :param in_max: input range maximum
        :param out_min: what input range minimum is mapped to
        :param out_max: what input range maximum is mapped to
        :return: mapping from value in linear input range to value in exponential output range (extrapolating if needed)
        """
        if in_min == in_max:
            if value == in_min and out_min == out_max:
                return out_min
            return None

        return math.pow(out_max / out_min, (value - in_min) / (in_max - in_min)) * out_min

    @staticmethod
    def explin(value, in_min, in_max, out_min, out_max):
        """
        maps value \in exponential range [in_min,in_max] corresponding value \in linear range [out_min, out_max]
        (extrapolating if possible)

        :param value: value to be mapped 
        :param in_min: input range minimum
        :param in_max: input range maximum
        :param out_min: what input range minimum is mapped to
        :param out_max: what input range maximum is mapped to
        :return: mapping from value in  exponential input range to value in linear output range 
        (extrapolating if possible)
        """
        if in_min == 0:
            return None
        if (value / in_min) < 0:
            return None
        if (in_max / in_min) < 0:
            return None

        return math.log(value / in_min) / math.log(in_max / in_min) * (out_max - out_min) + out_min

    @staticmethod
    def expexp(value, in_min, in_max, out_min, out_max):
        """
        maps value \in exponential range [in_min,in_max] corresponding value \in exponential range [out_min, out_max]
        (extrapolating if possible)

        :param value: value to be mapped 
        :param in_min: input range minimum
        :param in_max: input range maximum
        :param out_min: what input range minimum is mapped to
        :param out_max: what input range maximum is mapped to
        :return: mapping from value in  exponential input range to value in exponential output range 
        (extrapolating if possible)
        """
        if value == 0:
            return None
        if value / in_min < 0:
            return None
        if in_min == 0:
            return None
        if (in_max - in_min) < 0:
            return None

        return math.pow(out_max / out_min, math.log(value / in_min) / math.log(in_max / in_min)) * out_min

{'fraction_non_alphanumeric': 0.08489501016030707, 'fraction_numerical': 0.009708737864077669, 'mean_word_length': 1.9912221471978393, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6307769', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1300, 'n_words': 486}