Next / Previous / Contents / TCC Help System / NM Tech homepage

43.4. CensusTotal.__float__()

This method is used when computing statistics on the number of individuals in a census row. Refer to Section 40, “class NumberCell: Base class for numeric table cells” for a general discussion. In particular, here we implement the rule that if the total is in the undefined state (that is, the .total attribute is negative), the return value is 1.0.

cbchistlib.py
# - - -   C e n s u s T o t a l . _ _ f l o a t _ _

    def __float__(self):
        '''Return the floating value of self.
        '''
        if self.total is 0:
            return 0.0
        elif self.total < 0:
            return 1.0
        else:
            return float(self.total)