本文整理汇总了Python中RecoLuminosity.LumiDB.CommonUtil.is_floatstr方法的典型用法代码示例。如果您正苦于以下问题:Python CommonUtil.is_floatstr方法的具体用法?Python CommonUtil.is_floatstr怎么用?Python CommonUtil.is_floatstr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecoLuminosity.LumiDB.CommonUtil
的用法示例。
在下文中一共展示了CommonUtil.is_floatstr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fieldtotal
# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import is_floatstr [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
示例2: fieldvalues
# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import is_floatstr [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
示例3: _getnorm
# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import is_floatstr [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]
示例4: context
# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import is_floatstr [as 别名]
if options.beammode=='stable':
pbeammode = 'STABLE BEAMS'
if options.verbose:
print 'General configuration'
print '\tconnect: ',options.connect
print '\tauthpath: ',options.authpath
print '\tlumi data version: ',options.lumiversion
print '\tsiteconfpath: ',options.siteconfpath
print '\toutputfile: ',options.outputfile
print '\tscalefactor: ',options.scalefactor
if options.action=='recorded' and options.hltpath:
print 'Action: effective luminosity in hltpath: ',options.hltpath
else:
print 'Action: ',options.action
if options.normfactor:
if CommonUtil.is_floatstr(normfactor):
print '\tuse norm factor value ',normfactor
else:
print '\tuse specific norm factor name ',normfactor
else:
print '\tuse norm factor in context (amodetag,beamenergy)'
if options.runnumber: # if runnumber specified, do not go through other run selection criteria
print '\tselect specific run== ',options.runnumber
else:
print '\trun selections == '
print '\tinput selection file: ',options.inputfile
print '\tbeam mode: ',options.beammode
print '\tfill: ',options.fillnum
print '\tamodetag: ',options.amodetag
print '\tbegin: ',options.begin
print '\tend: ',options.end