def test_convert(self): self.assertAlmostEqual(1.304, uc.convert(1304, "us", "ms"), 2) self.assertAlmostEqual(0.001304, uc.convert(1304, "us", "s"), 2) self.assertAlmostEqual(95.37, uc.convert(100, "MB", "MiB"), 2) self.assertAlmostEqual(2000000, uc.convert(2000, "GB", "MB"), 2) self.assertAlmostEqual(1907348.63, uc.convert(2000, "GB", "MiB"), 2) self.assertAlmostEqual(0.8, uc.convert(100, "MBps", "Gbps"), 2) self.assertAlmostEqual(95.37, uc.convert(100, "MBps", "MiBps"), 2)
def parseDataSize(dataSize): parsedDataSize = parse(dataSize) if parsedDataSize == None: sys.exit("Can't parse data size '%s'" % (dataSize)) (quantity, unit) = parsedDataSize numBytes = convert(quantity, unit, "B") return int(numBytes)
def from_ase_units(self, value, quantity): return unitconversion.convert(value, quantity, 'ASE', self.parameters.units)