Beispiel #1
0
 def guess_units(self, guessunit=True):
     if guessunit:
         if isinstance(guessunit, string_types):
             varnames = [guessunit]
         elif isinstance(guessunit, (list, tuple, set, dict)):
             varnames = list(guessunit)
         else:
             varnames = self.allvarnames
             if self.comments:
                 varnames.extend(self.comments.property)
         for varname in varnames:
             unit = guess_unit_from_varname(varname)
             if varname in self and self[varname].unit is None:
                 if varname in self.ivardata:
                     olddim = self.ivardata[varname]
                     newdim = olddim.__class__(olddim, unit=unit)
                     self.replace_dim(olddim, newdim)
                 else:
                     self[varname].unit = unit
             if self.comments:
                 prop = self.comments.property
                 if varname in prop and prop[varname]:
                     v = prop[varname]
                     if getattr(v, "unit", "") is None:
                         v.unit = unit
Beispiel #2
0
 def guess_units(self, guessunit=True):
     if guessunit:
         if isinstance(guessunit, string_types):
             varnames = [guessunit]
         elif isinstance(guessunit, (list, tuple, set, dict)):
             varnames = list(guessunit)
         else:
             varnames = self.allvarnames
             if self.comments:
                 varnames.extend(self.comments.property)
         for varname in varnames:
             unit = guess_unit_from_varname(varname)
             if varname in self and self[varname].unit is None:
                 if varname in self.ivardata:
                     olddim = self.ivardata[varname]
                     newdim = olddim.__class__(olddim, unit=unit)
                     self.replace_dim(olddim, newdim)
                 else:
                     self[varname].unit = unit
             if self.comments:
                 prop = self.comments.property
                 if varname in prop and prop[varname]:
                     v = prop[varname]
                     if getattr(v, "unit", "") is None:
                         v.unit = unit
Beispiel #3
0
 def test_1(self):
     unit = helper.guess_unit_from_varname("Vds")
     self.assertEqual(unit, "V")