summaryrefslogtreecommitdiff
path: root/lib/param/float_.py
blob: 88ed06679077d3b38c0d28bb59805ad4cfc22287 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Defines the float param type"""
from param import Param
class Float(Param):
    """Defines the float param type
       Args:
           value: the value of the Float
           classname: the name of the class to which the param belongs
    """
    def __init__(self, value, classname=""):
        self._classname = classname
        super(Float, self).__init__(classname=classname)
        try:
            if value:
                self.value = float(value)
            else:
                self.value = 0.0
        except Exception as e:
            self.err_warn("Not a float: %s" % str(value))
            self.err_warn(str(e))
    def __int__(self):
        return int(self.value)

    def __float__(self):
        return float(self.value)