<commit_before>"""
This module provides the class Settings
"""
class Settings:
    """
    Stores all settings which are necessary for the Arudino
    """
    SPEED_PREFIX = b'A'
    LR_PREFIX = b'D'
    UD_PREFIX = b'E'
    FRONT_PREFIX = b'B'
    BACK_PREFIX = b'C'

    def __init__(self, speedSetting, leftRightSetting, upDownSetting,
                 frontSetting, backSetting):
        self.speed = speedSetting
        self.leftRight = leftRightSetting
        self.upDown = upDownSetting
        self.front = frontSetting
        self.back = backSetting

    def __str__(self):
        return str(self.speed) + str(self.leftRight) + str(self.upDown) + str(self.front) + str(self.back)

    def __bytes__(self):
        return bytes([self.speed,
                      self.leftRight,
                      self.upDown,
                      self.front,
                      self.back])

    def copy(self):
        """
        Creates an identical copy of these settings
        """
        return Settings(self.speed, self.leftRight, self.upDown,
                        self.front, self.back)

    def __eq__(self, comparison):
        """
        Checks if these settings exactly match the comparison
        """
        if not isinstance(comparison, Settings):
            return False
        if self.speed != comparison.speed:
            return False
        if self.leftRight != comparison.leftRight:
            return False
        if self.upDown != comparison.upDown:
            return False
        if self.front != comparison.front:
            return False
        if self.back != comparison.back:
            return False
        return True

    @staticmethod
    def GetDeltaSettings(original, comparison):
        return Settings(comparison.speed - original.speed,
                        comparison.leftRight - original.leftRight,
                        comparison.upDown - original.upDown,
                        comparison.front - original.front,
                        comparison.back - original.back)

    @staticmethod
    def EmptySettings():
        return Settings(0, 0, 0, 0, 0)


def KeepInBoundary(val, upperBound, underBound=0):
        if val > upperBound:
            return upperBound
        if val < underBound:
            return underBound
        return val<commit_msg>Slowly adapting to Arduino's new communication model<commit_after>"""
This module provides the class Settings
"""
class Settings:
    """
    Stores all settings which are necessary for the Arudino
    """
    SPEED_PREFIX = b'A'
    LR_PREFIX = b'D'
    UD_PREFIX = b'E'
    FRONT_PREFIX = b'B'
    BACK_PREFIX = b'C'

    def __init__(self, speedSetting, leftRightSetting, upDownSetting,
                 frontSetting, backSetting):
        self.speed = speedSetting
        self.leftRight = leftRightSetting
        self.upDown = upDownSetting
        self.front = frontSetting
        self.back = backSetting

    def __str__(self):
        return str(self.speed) + str(self.leftRight) + str(self.upDown) + str(self.front) + str(self.back)

    def __bytes__(self):
        return bytes([self.speed,
                      self.leftRight,
                      self.upDown,
                      self.front,
                      self.back])

    def copy(self):
        """
        Creates an identical copy of these settings
        """
        return Settings(self.speed, self.leftRight, self.upDown,
                        self.front, self.back)

    def __eq__(self, comparison):
        """
        Checks if these settings exactly match the comparison
        """
        if not isinstance(comparison, Settings):
            return False
        if self.speed != comparison.speed:
            return False
        if self.leftRight != comparison.leftRight:
            return False
        if self.upDown != comparison.upDown:
            return False
        if self.front != comparison.front:
            return False
        if self.back != comparison.back:
            return False
        return True

    def deltaBytes(self, comparison):
        """
        Returns the settings which are different with their prefixes. 
        The values from these Settings will be used, not from the 
        comparison. 
        """
        output = bytes()
        if self.speed != comparison.speed:
            output += self.SPEED_PREFIX
            output += bytes(self.speed)
        if self.leftRight != comparison.leftRight:
            output += self.LR_PREFIX
            output += bytes(self.leftRight)
        if self.upDown != comparison.upDown:
            output += self.UD_PREFIX
            output += bytes(self.upDown)
        if self.front != comparison.front:
            output += self.FRONT_PREFIX
            output += bytes(self.front)
        if self.back != comparison.back:
            output += self.BACK_PREFIX
            output += bytes(self.back)
        return output

    @staticmethod
    def GetDeltaSettings(original, comparison):
        return Settings(comparison.speed - original.speed,
                        comparison.leftRight - original.leftRight,
                        comparison.upDown - original.upDown,
                        comparison.front - original.front,
                        comparison.back - original.back)

    @staticmethod
    def EmptySettings():
        return Settings(0, 0, 0, 0, 0)


def KeepInBoundary(val, upperBound, underBound=0):
        if val > upperBound:
            return upperBound
        if val < underBound:
            return underBound
        return val
{'fraction_non_alphanumeric': 0.08369252873563218, 'fraction_numerical': 0.0021551724137931034, 'mean_word_length': 1.756930693069307, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7359940', 'n_tokens_mistral': 1443, 'n_tokens_neox': 1380, 'n_words': 388}