CMS 3D CMS Logo

Classes | Functions
Mixins Namespace Reference

Classes

class  _ConfigureComponent
 
class  _Labelable
 
class  _Parameterizable
 
class  _ParameterTypeBase
 
class  _SimpleParameterTypeBase
 
class  _SpecialImportRegistry
 
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 665 of file Mixins.py.

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

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

665 def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth=""):
666  if len(newParams):
667  #need to treat items both in params and myparams specially
668  for key,value in six.iteritems(newParams):
669  if key in params:
670  if value is None:
671  del params[key]
672  elif isinstance(value, dict):
673  if isinstance(params[key],_Parameterizable):
674  pset = params[key]
675  p =pset.parameters_()
676  oldkeys = set(p.keys())
678  value,errorRaiser,
679  ("%s.%s" if isinstance(key, str) else "%s[%s]")%(keyDepth,key))
680  for k,v in six.iteritems(p):
681  setattr(pset,k,v)
682  oldkeys.discard(k)
683  for k in oldkeys:
684  delattr(pset,k)
685  elif isinstance(params[key],_ValidatingParameterListBase):
686  if any(not isinstance(k, int) for k in value.keys()):
687  raise TypeError("Attempted to change a list using a dict whose keys are not integers")
688  plist = params[key]
689  if any((k < 0 or k >= len(plist)) for k in value.keys()):
690  raise IndexError("Attempted to set an index which is not in the list")
691  p = dict(enumerate(plist))
693  value,errorRaiser,
694  ("%s.%s" if isinstance(key, str) else "%s[%s]")%(keyDepth,key))
695  for k,v in six.iteritems(p):
696  plist[k] = v
697  else:
698  raise ValueError("Attempted to change non PSet value "+keyDepth+" using a dictionary")
699  elif isinstance(value,_ParameterTypeBase) or (isinstance(key, int)) or isinstance(value, _Parameterizable):
700  params[key] = value
701  else:
702  params[key].setValue(value)
703  else:
704  if isinstance(value,_ParameterTypeBase) or isinstance(value, _Parameterizable):
705  params[key]=value
706  else:
707  errorRaiser(key)
708 
709 
def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth="")
Definition: Mixins.py:665
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 659 of file Mixins.py.

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

659 def saveOrigin(obj, level):
660  import sys
661  fInfo = inspect.getframeinfo(sys._getframe(level+1))
662  obj._filename = fInfo.filename
663  obj._lineNumber =fInfo.lineno
664 
def saveOrigin(obj, level)
Definition: Mixins.py:659