当前位置: 首页>>代码示例>>Python>>正文


Python Unit.get方法代码示例

本文整理汇总了Python中unit.Unit.get方法的典型用法代码示例。如果您正苦于以下问题:Python Unit.get方法的具体用法?Python Unit.get怎么用?Python Unit.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unit.Unit的用法示例。


在下文中一共展示了Unit.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: value_unit_to_number

# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import get [as 别名]
 def value_unit_to_number(self, param, value):
     # string is of the form "32.3L"
     unit = value[-1]
     #v = float(value[:-1])
     v = self.str_to_float(param, value[:-1])
     if (Unit.get(param) != unit):
         v = Unit.convert(unit, Unit.get(param), v)
     return round(v, self.precision)
开发者ID:yashkarandikar,项目名称:ucsd-fitness,代码行数:10,代码来源:param_formatter.py

示例2: __init__

# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import get [as 别名]
 def __init__(self, sport, xparam, yparam, xvals = None, yvals = None):
     self.xparam = xparam
     self.yparam = yparam
     self.sport = sport
     if (xvals is None):
         xvals = []
     if (yvals is None):
         yvals = []
     self.xvals = xvals
     self.yvals = yvals
     self.xlabel = self.xparam + " (%s)"%(Unit.get(self.xparam))
     self.ylabel = self.yparam + " (%s)"%(Unit.get(self.yparam))
开发者ID:yashkarandikar,项目名称:ucsd-fitness,代码行数:14,代码来源:plot_data.py

示例3: value_space_unit_to_number

# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import get [as 别名]
 def value_space_unit_to_number(self, param, value):
     # default format is "<value> <unit>"
     if (value == "-"):
         raise InvalidValueException(param, value)
     parts = value.split()
     unit = parts[1]
     if (unit == "min/mi" and (":" in parts[0])):
         v_parts = parts[0].split(":")
         #v = float(v_parts[0]) + float(v_parts[1])/60.0  # convert to float minutes value
         v = self.str_to_float(param, v_parts[0]) + self.str_to_float(param, v_parts[1])/60.0  # convert to float minutes value
     else:
         #v = float(parts[0])
         v = self.str_to_float(param, parts[0])
     if (Unit.get(param) != unit):
         v = Unit.convert(unit, Unit.get(param), v)
     return round(v, self.precision)
开发者ID:yashkarandikar,项目名称:ucsd-fitness,代码行数:18,代码来源:param_formatter.py

示例4: duration_to_number

# 需要导入模块: from unit import Unit [as 别名]
# 或者: from unit.Unit import get [as 别名]
 def duration_to_number(self, param, value):
     # the value is of the form 16m:31s
     parts = value.split(":")
     v = 0
     assert(param == "Duration")
     assert(Unit.get("Duration") == "s")  # following code assumes the unit is seconds
     for p in parts:
         #p_value = int(p[0:len(p) - 1])
         p_value = self.str_to_float(param, p[0:len(p) - 1])
         p_unit = p[len(p) - 1]
         if (p_unit == "s"):
             v += p_value
         elif(p_unit == "m"):
             v += p_value * 60
         elif(p_unit == "h"):
             v += p_value * 3600
         elif(p_unit == "d"):
             v += p_value * 86400
         else:
             raise Exception("Invalid time unit.. param = %s, value = %s" % (param, value))
     return v
开发者ID:yashkarandikar,项目名称:ucsd-fitness,代码行数:23,代码来源:param_formatter.py


注:本文中的unit.Unit.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。