示例#1
0
 def _reduceSelf(self):
     """
     Parse our unit and reduce ourselves to the smallest representation
     """
     if isinstance(self.unit, basestring):
         self.unit = self.__findUnit()
     a = self.amount * self.prefix
     self.amount, self.prefix = Prefix.closestPrefix(a)
示例#2
0
 def testSimplePrefix(self):
     r = Prefix.closestPrefix(1000)
     assert r == (1.0, Prefix.Prefixes.kilo)
示例#3
0
 def testNegativePrefix(self):
     r = Prefix.closestPrefix(-1000)
     assert r == (-1.0, Prefix.Prefixes.kilo), r
示例#4
0
 def testSmallPrefix(self):
     r = Prefix.closestPrefix(0.05)
     assert r == (50, Prefix.Prefixes.milli)
示例#5
0
 def testComplexPrefix(self):
     r = Prefix.closestPrefix(1024)
     assert r == (1.024, Prefix.Prefixes.kilo)