Variables | |
list | a = [1,2,3,4,5] |
tuple | b = array.array('f') |
list | lst = ['I1','I2','I1','I3','I4','I4','I7','I7','I7','I7','I7'] |
tuple | myblob = packArraytoBlob(a) |
list | nested = [[[1,2],[6,6,8]],[[3,4,5],[4,5]]] |
tuple | pp = json.loads(result) |
tuple | result = tolegalJSON('{1:[],2:[[1,3],[4,5]]}') |
list | seqbag = [[1,2,3],[1,3,3],[1,4,6],[4,5,6,7],[8,9]] |
This module collects some frequently used helper functions
def CommonUtil.count_dups | ( | l | ) |
report the number of duplicates in a python list
Definition at line 137 of file CommonUtil.py.
def CommonUtil.findInList | ( | mylist, | |
element | |||
) |
check if an element is in the list
Definition at line 110 of file CommonUtil.py.
def CommonUtil.flatten | ( | obj | ) |
Given nested lists or tuples, returns a single flattened list
Definition at line 4 of file CommonUtil.py.
def CommonUtil.guessUnit | ( | inverseubval | ) |
input: float value in 1/ub output: printable value (value(float),unit(str)) unit in [1/kb,1/b,1/mb,1/ub,1/nb,1/pb,1/fb]
Definition at line 59 of file CommonUtil.py.
def CommonUtil.inclusiveRange | ( | start, | |
stop, | |||
step | |||
) |
return range including the stop value
Definition at line 190 of file CommonUtil.py.
def CommonUtil.is_floatstr | ( | s | ) |
test if a string can be converted to a float
Definition at line 128 of file CommonUtil.py.
def CommonUtil.is_intstr | ( | s | ) |
test if a string can be converted to a int
Definition at line 120 of file CommonUtil.py.
def CommonUtil.lumiUnitForPrint | ( | t | ) |
input : largest lumivalue output: (unitstring,denomitor)
Definition at line 30 of file CommonUtil.py.
def CommonUtil.pack | ( | high, | |
low | |||
) |
pack high,low 32bit unsigned int to one unsigned 64bit long long Note:the print value of result number may appear signed, if the sign bit is used.
Definition at line 154 of file CommonUtil.py.
def CommonUtil.packArraytoBlob | ( | iarray | ) |
Inputs: inputarray: a python array
Definition at line 220 of file CommonUtil.py.
def CommonUtil.packListstrtoCLOB | ( | iListstr, | |
separator = ' |
|||
) |
pack list of string of comma separated large string CLOB
Definition at line 244 of file CommonUtil.py.
def CommonUtil.packToString | ( | high, | |
low | |||
) |
pack high,low 32bit unsigned int to one unsigned 64bit long long in string format Note:the print value of result number may appear signed, if the sign bit is used.
Definition at line 160 of file CommonUtil.py.
def CommonUtil.pairwise | ( | lst | ) |
yield item i and item i+1 in lst. e.g. (lst[0], lst[1]), (lst[1], lst[2]), ..., (lst[-1], None) from http://code.activestate.com/recipes/409825-look-ahead-one-item-during-iteration
Definition at line 98 of file CommonUtil.py.
def CommonUtil.parselumicorrector | ( | correctorStr | ) |
output: (functionname,parametersinuppercase[])
Definition at line 271 of file CommonUtil.py.
def CommonUtil.parseTime | ( | iTime | ) |
input string of the ("^\d\d/\d\d/\d\d \d\d:\d\d:\d\d$|^\d{6}$|^\d{4}$" format output (runnum,fillnum,timeStr)
Definition at line 14 of file CommonUtil.py.
def CommonUtil.splitlistToRangeString | ( | inPut | ) |
Definition at line 256 of file CommonUtil.py.
def CommonUtil.timeStamptoDate | ( | i | ) |
convert 64bit timestamp to local date in string format
Definition at line 176 of file CommonUtil.py.
def CommonUtil.timeStamptoUTC | ( | i | ) |
convert 64bit timestamp to Universal Time in string format
Definition at line 180 of file CommonUtil.py.
def CommonUtil.tolegalJSON | ( | inputstring | ) |
convert json like string to legal json string add double quote around json keys if they are not there, change single quote to double quote around keys
Definition at line 200 of file CommonUtil.py.
def CommonUtil.transposed | ( | lists, | |
defaultval = None |
|||
) |
transposing list of lists from http://code.activestate.com/recipes/410687-transposing-a-list-of-lists-with-different-lengths/
Definition at line 146 of file CommonUtil.py.
def CommonUtil.unpack | ( | i | ) |
unpack 64bit unsigned long long into 2 32bit unsigned int, return tuple (high,low)
Definition at line 166 of file CommonUtil.py.
def CommonUtil.unpackBlobtoArray | ( | iblob, | |
itemtypecode | |||
) |
Inputs: iblob: coral.Blob itemtypecode: python array type code
Definition at line 229 of file CommonUtil.py.
def CommonUtil.unpackCLOBtoListstr | ( | iStr, | |
separator = ' |
|||
) |
unpack a large string to list of string
Definition at line 250 of file CommonUtil.py.
def CommonUtil.unpackFromString | ( | i | ) |
unpack 64bit unsigned long long in string format into 2 32bit unsigned int, return tuple(high,low)
Definition at line 172 of file CommonUtil.py.
def CommonUtil.unpackLumiid | ( | i | ) |
unpack 64bit lumiid to dictionary {'run','lumisection'}
Definition at line 185 of file CommonUtil.py.
list CommonUtil.a = [1,2,3,4,5] |
Definition at line 283 of file CommonUtil.py.
tuple CommonUtil.b = array.array('f') |
Definition at line 315 of file CommonUtil.py.
list CommonUtil.lst = ['I1','I2','I1','I3','I4','I4','I7','I7','I7','I7','I7'] |
Definition at line 287 of file CommonUtil.py.
tuple CommonUtil.myblob = packArraytoBlob(a) |
Definition at line 312 of file CommonUtil.py.
list CommonUtil.nested = [[[1,2],[6,6,8]],[[3,4,5],[4,5]]] |
Definition at line 281 of file CommonUtil.py.
Referenced by edm.contextual_find().
tuple CommonUtil.pp = json.loads(result) |
Definition at line 296 of file CommonUtil.py.
tuple CommonUtil.result = tolegalJSON('{1:[],2:[[1,3],[4,5]]}') |
Definition at line 294 of file CommonUtil.py.
list CommonUtil.seqbag = [[1,2,3],[1,3,3],[1,4,6],[4,5,6,7],[8,9]] |
Definition at line 289 of file CommonUtil.py.