<commit_before># Copyright (c) 2015 <NAME>.V.
# Uranium is released under the terms of the AGPLv3 or higher.


##  An RGBA color value.
#
#   This class represents an RGBA color value, in the range of 0.0 to 1.0.
class Color:
    def __init__(self, r = 0, g = 0, b = 0, a = 0):
        self._r = r if type(r) is float else r / 255
        self._g = g if type(g) is float else g / 255
        self._b = b if type(b) is float else b / 255
        self._a = a if type(a) is float else a / 255

    @property
    def r(self):
        return self._r

    def setR(self, value):
        self.setValues(value, self._g, self._b, self._a)

    @property
    def g(self):
        return self._g

    def setG(self, value):
        self.setValues(self._r, value, self._b, self._a)

    @property
    def b(self):
        return self._b

    def setB(self, value):
        self.setValues(self._r, self._g, value, self._a)

    @property
    def a(self):
        return self._a

    def setA(self, value):
        self.setValues(self._r, self._g, self._b, value)

    def setValues(self, r, g, b, a):
        self._r = r if type(r) is float else r / 255
        self._g = g if type(g) is float else g / 255
        self._b = b if type(b) is float else b / 255
        self._a = a if type(a) is float else a / 255

    def __eq__(self, other):
        return self._r == other._r and self._g == other._g and self._b == other._b and self._a == other._a

    def __hash__(self):
        return (self._r, self._g, self._b, self._a).__hash__()

    def __repr__(self):
        return "Color(r = {0}, g = {1}, b = {2}, a = {3})".format(self._r, self._g, self._b, self._a)

    ##  Returns a new Color constructed from a 32-bit integer in ARGB order.
    #
    #   \param value A 32-bit integer representing a color in ARGB order.
    #   \return A Color constructed from the components of value.
    @staticmethod
    def fromARGB(value):
        return Color(
            (value & 0x00ff0000) >> 16,
            (value & 0x0000ff00) >> 8,
            (value & 0x000000ff) >> 0,
            (value & 0xff000000) >> 24
        )<commit_msg>Convenience function to convert a UM.Math.Color to/from a #RRGGBB hex-string<commit_after># Copyright (c) 2015 Ultimaker B.V.
# Uranium is released under the terms of the AGPLv3 or higher.


##  An RGBA color value.
#
#   This class represents an RGBA color value, in the range of 0.0 to 1.0.
class Color:
    def __init__(self, r = 0, g = 0, b = 0, a = 0):
        self._r = r if type(r) is float else r / 255
        self._g = g if type(g) is float else g / 255
        self._b = b if type(b) is float else b / 255
        self._a = a if type(a) is float else a / 255

    @property
    def r(self):
        return self._r

    def setR(self, value):
        self.setValues(value, self._g, self._b, self._a)

    @property
    def g(self):
        return self._g

    def setG(self, value):
        self.setValues(self._r, value, self._b, self._a)

    @property
    def b(self):
        return self._b

    def setB(self, value):
        self.setValues(self._r, self._g, value, self._a)

    @property
    def a(self):
        return self._a

    def setA(self, value):
        self.setValues(self._r, self._g, self._b, value)

    def setValues(self, r, g, b, a):
        self._r = r if type(r) is float else r / 255
        self._g = g if type(g) is float else g / 255
        self._b = b if type(b) is float else b / 255
        self._a = a if type(a) is float else a / 255

    def __eq__(self, other):
        return self._r == other._r and self._g == other._g and self._b == other._b and self._a == other._a

    def __hash__(self):
        return (self._r, self._g, self._b, self._a).__hash__()

    def __repr__(self):
        return "Color(r = {0}, g = {1}, b = {2}, a = {3})".format(self._r, self._g, self._b, self._a)

    ##  Returns a new Color constructed from a 32-bit integer in ARGB order.
    #
    #   \param value A 32-bit integer representing a color in ARGB order.
    #   \return A Color constructed from the components of value.
    @staticmethod
    def fromARGB(value):
        return Color(
            (value & 0x00ff0000) >> 16,
            (value & 0x0000ff00) >> 8,
            (value & 0x000000ff) >> 0,
            (value & 0xff000000) >> 24
        )

    ##  Returns a new Color constructed from a 7-character string "#RRGGBB" format.
    #
    #   \param value A 7-character string representing a color in "#RRGGBB" format.
    #   \return A Color constructed from the components of value.
    @staticmethod
    def fromRGBString(value):
        return Color(
            int(value[1:3], 16) / 255,
            int(value[3:5], 16) / 255,
            int(value[5:7], 16) / 255,
            1.0
        )

    ##  Returns a 7-character string in "#RRGGBB" format representing the color.
    #
    #   \return A 7-character string representing a color in "#RRGGBB" format.
    def toRGBString(self):
        value = ((int(self._r * 255) & 255) << 16) + \
                ((int(self._g * 255) & 255) << 8) + \
                (int(self._b * 255) & 255)
        return "#%s" % hex(value)[2:]
{'fraction_non_alphanumeric': 0.12325038880248834, 'fraction_numerical': 0.04024105754276827, 'mean_word_length': 2.015826494724502, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 20, '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': '1497000', 'n_tokens_mistral': 1930, 'n_tokens_neox': 1713, 'n_words': 607}