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


Python CommonUtil.is_intstr方法代码示例

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


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

示例1: fieldvalues

# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import is_intstr [as 别名]
 def fieldvalues(self,fieldname,fieldtype):
     '''
     given the input result field name and typem return the list of values
     '''
     fieldidx=None
     result=[]
     try:
         fieldidx=self.__inputResultHeader.index(fieldname)
     except:
         print('field ',fieldname,' not found')
         raise RuntimeError('field')
     for r in self.__inputResult:
         stringvalue=r[fieldidx]
         if fieldtype in ['int','unsigned int']:
             if not CommonUtil.is_intstr(stringvalue):
                 print('field ',fieldname,' is not integer type')
                 raise RuntimeError('field')
             else:
                 result.append(int(stringvalue))
                 continue
         elif fieldtype in ['float']:
             if not CommonUtil.is_floatstr(stringvalue):
                 print('field ',fieldname,' is not float type')
                 raise RuntimeError('field')
             else:
                 result.append(float(stringvalue))
                 contine
         elif  fieldtype in ['string','str']:
             result.append(stringvalue)
         else:
             raise RuntimeError('unsupported type '+fieldtype)
     return result
开发者ID:Moanwar,项目名称:cmssw,代码行数:34,代码来源:inputFilesetParser.py

示例2: fieldtotal

# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import is_intstr [as 别名]
 def fieldtotal(self,fieldname,fieldtype):
     '''
     given the input result field name and type, return the total
     '''
     fieldidx=None
     result=0
     try:
         fieldidx=self.__inputResultHeader.index(fieldname)
     except:
         print('field ',fieldname,' not found')
         raise
     for r in self.__inputResult:
         stringvalue=r[fieldidx]
         if fieldtype in ['int','unsigned int']:
             if not CommonUtil.is_intstr(stringvalue):
                 print('field ',fieldname,' is not integer type')
                 raise
             else:
                 result=int(result)+int(stringvalue)
                 continue
         elif fieldtype in ['float'] :
             if not CommonUtil.is_floatstr(stringvalue):
                 print('field ',fieldname,' is not float type')
                 raise
             else:
                 result=float(result)+float(stringvalue)
                 continue
         else:
             raise RunTimeError('cannot sum types other than int ,float')
     return result
开发者ID:Moanwar,项目名称:cmssw,代码行数:32,代码来源:inputFilesetParser.py

示例3: runsWithresult

# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import is_intstr [as 别名]
 def runsWithresult(self):
     '''
     output: [run,run,...]
     '''
     result={}
     for f in self.__inputresultfiles:
         csvReader=csv.reader(open(f),delimiter=',')
         for row in csvReader:
             field0=str(row[0]).strip()
             if not CommonUtil.is_intstr(field0):
                 continue
             runnumber=int(field0)
             if runnumber not in result:
                 result[runnumber]=None
     return result.keys()
开发者ID:Moanwar,项目名称:cmssw,代码行数:17,代码来源:inputFilesetParser.py

示例4: _getnorm

# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import is_intstr [as 别名]
def _getnorm(schema,norm):
    if isinstance(norm,int) or isinstance(norm,float) or CommonUtil.is_floatstr(norm) or CommonUtil.is_intstr(norm):
        return float(norm)
    if not isinstance(norm,str):
        raise ValueError('wrong parameter type')
    normdataid=dataDML.guessnormIdByName(schema,norm)
    normresult=dataDML.luminormById(schema,normdataid)
    return normresult[2]
开发者ID:mariadalfonso,项目名称:cmg-wmass-44X,代码行数:10,代码来源:lumiCalcAPI.py


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