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 34 of file FrontierCondition_GT_autoExpress_cfi.py.

References electrons_cff.bool, GetRecoTauVFromDQM_MC_cff.next, and lumiQTWidget.t.

Referenced by FrontierCondition_GT_autoExpress_cfi.Tier0Handler.getGlobalTag().

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