CMS 3D CMS Logo

Classes | Functions
FrontierCondition_GT_autoExpress_cfi Namespace Reference

Classes

class  Tier0Error
 
class  Tier0Handler
 

Functions

def unique (seq, keepstr=True)
 

Function Documentation

def FrontierCondition_GT_autoExpress_cfi.unique (   seq,
  keepstr = True 
)

Definition at line 35 of file FrontierCondition_GT_autoExpress_cfi.py.

References GetRecoTauVFromDQM_MC_cff.next, and lumiQTWidget.t.

Referenced by FrontierCondition_GT_autoExpress_cfi.Tier0Handler.getGlobalTag().

35 def unique(seq, keepstr=True):
36  t = type(seq)
37  if t in (unicode, str):
38  t = (list, t('').join)[bool(keepstr)]
39  try:
40  remaining = set(seq)
41  seen = set()
42  return t(c for c in seq if (c in remaining and not remaining.remove(c)))
43  except TypeError: # hashing didn't work, see if seq is sortable
44  try:
45  from itertools import groupby
46  s = sorted(enumerate(seq),key=lambda i_v1:(i_v1[1],i_v1[0]))
47  return t(next(g) for k,g in groupby(s, lambda i_v: i_v[1]))
48  except: # not sortable, use brute force
49  seen = []
50  return t(c for c in seq if not (c in seen or seen.append(c)))
51