예제 #1
0
파일: readbase.py 프로젝트: ychaim/hftools
def fix_unit(db, varname):
    res = reg_varunit.match(varname)
    if res:
        vname, unit = res.groups()
        mul, unit = unit_to_multiplier(unit)
        #        db.rename(varname, vname)
        if varname in db.ivardata:
            olddim = db.ivardata[varname]
            newdim = olddim.__class__(olddim,
                                      name=vname,
                                      data=olddim.data * mul,
                                      unit=unit)
            db.replace_dim(olddim, newdim)
        else:
            db.rename(varname, vname)
            db[vname] = db[vname] * mul
            db[vname].unit = unit
예제 #2
0
 def test_4(self):
     self.assertEqual(unit_to_multiplier("#"), (1, None))
예제 #3
0
 def test_3(self):
     self.assertEqual(unit_to_multiplier("%"), (.01, None))
예제 #4
0
 def test_2(self):
     self.assertEqual(unit_to_multiplier("mXYZ"), (1, "mXYZ"))
예제 #5
0
 def test_1(self):
     self.assertEqual(unit_to_multiplier("s"), (1, "s"))
예제 #6
0
 def test_4(self):
     self.assertEqual(unit_to_multiplier("#"), (1, None))
예제 #7
0
 def test_3(self):
     self.assertEqual(unit_to_multiplier("%"), (.01, None))
예제 #8
0
 def test_2(self):
     self.assertEqual(unit_to_multiplier("mXYZ"), (1, "mXYZ"))
예제 #9
0
 def test_1(self):
     self.assertEqual(unit_to_multiplier("s"), (1, "s"))