CMS 3D CMS Logo

Classes | Functions | Variables
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)
 

Variables

 specialImportRegistry
 

Function Documentation

◆ _modifyParametersFromDict()

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

Definition at line 703 of file Mixins.py.

703 def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth=""):
704  if len(newParams):
705  #need to treat items both in params and myparams specially
706  for key,value in six.iteritems(newParams):
707  if key in params:
708  if value is None:
709  del params[key]
710  elif isinstance(value, dict):
711  if isinstance(params[key],_Parameterizable):
712  pset = params[key]
713  p =pset.parameters_()
714  oldkeys = set(p.keys())
716  value,errorRaiser,
717  ("%s.%s" if isinstance(key, str) else "%s[%s]")%(keyDepth,key))
718  for k,v in six.iteritems(p):
719  setattr(pset,k,v)
720  oldkeys.discard(k)
721  for k in oldkeys:
722  delattr(pset,k)
723  elif isinstance(params[key],_ValidatingParameterListBase):
724  if any(not isinstance(k, int) for k in value.keys()):
725  raise TypeError("Attempted to change a list using a dict whose keys are not integers")
726  plist = params[key]
727  if any((k < 0 or k >= len(plist)) for k in value.keys()):
728  raise IndexError("Attempted to set an index which is not in the list")
729  p = dict(enumerate(plist))
731  value,errorRaiser,
732  ("%s.%s" if isinstance(key, str) else "%s[%s]")%(keyDepth,key))
733  for k,v in six.iteritems(p):
734  plist[k] = v
735  else:
736  raise ValueError("Attempted to change non PSet value "+keyDepth+" using a dictionary")
737  elif isinstance(value,_ParameterTypeBase) or (isinstance(key, int)) or isinstance(value, _Parameterizable):
738  params[key] = value
739  else:
740  params[key].setValue(value)
741  else:
742  if isinstance(value,_ParameterTypeBase) or isinstance(value, _Parameterizable):
743  params[key]=value
744  else:
745  errorRaiser(key)
746 
747 

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

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

◆ saveOrigin()

def Mixins.saveOrigin (   obj,
  level 
)

Definition at line 697 of file Mixins.py.

697 def saveOrigin(obj, level):
698  import sys
699  fInfo = inspect.getframeinfo(sys._getframe(level+1))
700  obj._filename = fInfo.filename
701  obj._lineNumber =fInfo.lineno
702 

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

Variable Documentation

◆ specialImportRegistry

Mixins.specialImportRegistry

Definition at line 54 of file Mixins.py.

reco::JetExtendedAssociation::setValue
bool setValue(Container &, const reco::JetBaseRef &, const JetExtendedData &)
associate jet with value. Returns false and associate nothing if jet is already associated
Definition: JetExtendedAssociation.cc:44
any
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:38
Mixins.saveOrigin
def saveOrigin(obj, level)
Definition: Mixins.py:697
Mixins._modifyParametersFromDict
def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth="")
Definition: Mixins.py:703