<commit_before>"""Kraken - objects.Attributes.FloatAttribute module.

Classes:
FloatAttribute - Base Attribute.

"""

from number_attribute import NumberAttribute
from kraken.core.kraken_system import ks

class FloatAttribute(NumberAttribute):
    """Float Attribute. Implemented value type checking and limiting."""

    def __init__(self, name, value=0.0, minValue=None, maxValue=None):
        super(FloatAttribute, self).__init__(name, value)

        if minValue is None:
            if value < 0.0:
                self.setMin(value)
            else:
                self.setMin(0.0)

        if maxValue is None:
            if value == 0.0:
                self.setMax(1.0)
            else:
                self.setMax(value * 3.0)

        assert type(self.value) in (int, float), "Value is not of type 'int' or 'float'."


    def setValue(self, value):
        """Sets the value of the attribute.

        Arguments:
        value -- Value to set the attribute to.

        Return:
        True if successful.

        """

        if type(value) not in (int, float):
            raise TypeError("Value is not of type 'int' or 'float'.")

        if value < self.min:
            raise ValueError("Value is less than attribute minimum.")
        elif value > self.max:
            raise ValueError("Value is greater than attribute maximum.")

        super(FloatAttribute, self).setValue(value)

        return True

    def getRTVal(self):
        """Returns and RTVal object for this attribute.

        Return:
        RTVal

        """
        return ks.rtVal('Scalar', self.value)


        <commit_msg>add minValue and maxValue in FloatAttribute super function<commit_after>"""Kraken - objects.Attributes.FloatAttribute module.

Classes:
FloatAttribute - Base Attribute.

"""

from number_attribute import NumberAttribute
from kraken.core.kraken_system import ks

class FloatAttribute(NumberAttribute):
    """Float Attribute. Implemented value type checking and limiting."""

    def __init__(self, name, value=0.0, minValue=None, maxValue=None):
        super(FloatAttribute, self).__init__(name, value, minValue=minValue, maxValue=maxValue)

        if minValue is None:
            if value < 0.0:
                self.setMin(value)
            else:
                self.setMin(0.0)

        if maxValue is None:
            if value == 0.0:
                self.setMax(1.0)
            else:
                self.setMax(value * 3.0)

        assert type(self.value) in (int, float), "Value is not of type 'int' or 'float'."


    def setValue(self, value):
        """Sets the value of the attribute.

        Arguments:
        value -- Value to set the attribute to.

        Return:
        True if successful.

        """

        if type(value) not in (int, float):
            raise TypeError("Value is not of type 'int' or 'float'.")

        if value < self.min:
            raise ValueError("Value is less than attribute minimum.")
        elif value > self.max:
            raise ValueError("Value is greater than attribute maximum.")

        super(FloatAttribute, self).setValue(value)

        return True

    def getRTVal(self):
        """Returns and RTVal object for this attribute.

        Return:
        RTVal

        """
        return ks.rtVal('Scalar', self.value)



{'fraction_non_alphanumeric': 0.09761976498945465, 'fraction_numerical': 0.0072310937029225674, 'mean_word_length': 2.0458715596330275, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5758960', 'n_tokens_mistral': 928, 'n_tokens_neox': 883, 'n_words': 293}