本文整理汇总了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
示例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
示例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()
示例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]