CMS 3D CMS Logo

Classes | Functions
Mixins Namespace Reference

Classes

class  _ConfigureComponent
 
class  _Labelable
 
class  _Parameterizable
 
class  _ParameterTypeBase
 
class  _SimpleParameterTypeBase
 
class  _TypedParameterizable
 
class  _Unlabelable
 
class  _ValidatingListBase
 
class  _ValidatingParameterListBase
 
class  PrintOptions
 
class  TestList
 
class  testMixins
 
class  UsingBlock
 

Functions

def _modifyParametersFromDict (params, newParams, errorRaiser, keyDepth="")
 
def saveOrigin (obj, level)
 

Function Documentation

def Mixins._modifyParametersFromDict (   params,
  newParams,
  errorRaiser,
  keyDepth = "" 
)
private

Definition at line 628 of file Mixins.py.

References any(), cmsPerfStripChart.dict, and reco::JetExtendedAssociation.setValue().

Referenced by Config._ParameterModifier.__call__(), Mixins._TypedParameterizable.clone(), and Types.PSet.clone().

628 def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth=""):
629  if len(newParams):
630  #need to treat items both in params and myparams specially
631  for key,value in newParams.iteritems():
632  if key in params:
633  if value is None:
634  del params[key]
635  elif isinstance(value, dict):
636  if isinstance(params[key],_Parameterizable):
637  pset = params[key]
638  p =pset.parameters_()
640  value,errorRaiser,
641  ("%s.%s" if type(key)==str else "%s[%s]")%(keyDepth,key))
642  for k,v in p.iteritems():
643  setattr(pset,k,v)
644  elif isinstance(params[key],_ValidatingParameterListBase):
645  if any(type(k) != int for k in value.keys()):
646  raise TypeError("Attempted to change a list using a dict whose keys are not integers")
647  plist = params[key]
648  if any((k < 0 or k >= len(plist)) for k in value.keys()):
649  raise IndexError("Attempted to set an index which is not in the list")
650  p = dict(enumerate(plist))
652  value,errorRaiser,
653  ("%s.%s" if type(key)==str else "%s[%s]")%(keyDepth,key))
654  for k,v in p.iteritems():
655  plist[k] = v
656  else:
657  raise ValueError("Attempted to change non PSet value "+keyDepth+" using a dictionary")
658  elif isinstance(value,_ParameterTypeBase) or (type(key) == int):
659  params[key] = value
660  else:
661  params[key].setValue(value)
662  else:
663  if isinstance(value,_ParameterTypeBase):
664  params[key]=value
665  else:
666  errorRaiser(key)
667 
668 
def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth="")
Definition: Mixins.py:628
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
bool setValue(Container &, const reco::JetBaseRef &, const JetExtendedData &)
associate jet with value. Returns false and associate nothing if jet is already associated ...
def Mixins.saveOrigin (   obj,
  level 
)

Definition at line 619 of file Mixins.py.

Referenced by Modules.ESSource.__init__(), Modules._Module.__init__(), Mixins._TypedParameterizable.__init__(), and Mixins._TypedParameterizable.clone().

619 def saveOrigin(obj, level):
620  #frame = inspect.stack()[level+1]
621  frame = inspect.getframeinfo(inspect.currentframe(level+1))
622  # not safe under old python versions
623  #obj._filename = frame.filename
624  #obj._lineNumber = frame.lineno
625  obj._filename = frame[0]
626  obj._lineNumber = frame[1]
627 
def saveOrigin(obj, level)
Definition: Mixins.py:619