Пример #1
0
 def _do_op(cls, self, other, op):
     first, second = cls(self), cls(other)
     units = second.units or first.units
     value = op(float(first), float(second))
     value /= CONV_FACTOR.get(units, 1.0)
     return cls((value, units))
Пример #2
0
 def __float__(self):
     return self.value * CONV_FACTOR.get(self.units, 1.0)
Пример #3
0
 def __float__(self):
     return self.value * CONV_FACTOR.get(self.units, 1.0)
Пример #4
0
 def _do_op(cls, self, other, op):
     first, second = cls(self), cls(other)
     units = second.units or first.units
     value = op(float(first), float(second))
     value /= CONV_FACTOR.get(units, 1.0)
     return cls((value, units))
Пример #5
0
    def _do_op(cls, self, other, op):
        value = op(float(self), float(other))
        value /= CONV_FACTOR.get(self.units or other.units, 1.0)

        return cls((value, self.units or other.units))