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 629 of file Mixins.py.

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

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

629 def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth=""):
630  if len(newParams):
631  #need to treat items both in params and myparams specially
632  for key,value in six.iteritems(newParams):
633  if key in params:
634  if value is None:
635  del params[key]
636  elif isinstance(value, dict):
637  if isinstance(params[key],_Parameterizable):
638  pset = params[key]
639  p =pset.parameters_()
640  oldkeys = set(p.keys())
642  value,errorRaiser,
643  ("%s.%s" if isinstance(key, str) else "%s[%s]")%(keyDepth,key))
644  for k,v in six.iteritems(p):
645  setattr(pset,k,v)
646  oldkeys.discard(k)
647  for k in oldkeys:
648  delattr(pset,k)
649  elif isinstance(params[key],_ValidatingParameterListBase):
650  if any(not isinstance(k, int) for k in value.keys()):
651  raise TypeError("Attempted to change a list using a dict whose keys are not integers")
652  plist = params[key]
653  if any((k < 0 or k >= len(plist)) for k in value.keys()):
654  raise IndexError("Attempted to set an index which is not in the list")
655  p = dict(enumerate(plist))
657  value,errorRaiser,
658  ("%s.%s" if isinstance(key, str) else "%s[%s]")%(keyDepth,key))
659  for k,v in six.iteritems(p):
660  plist[k] = v
661  else:
662  raise ValueError("Attempted to change non PSet value "+keyDepth+" using a dictionary")
663  elif isinstance(value,_ParameterTypeBase) or (isinstance(key, int)):
664  params[key] = value
665  else:
666  params[key].setValue(value)
667  else:
668  if isinstance(value,_ParameterTypeBase):
669  params[key]=value
670  else:
671  errorRaiser(key)
672 
673 
def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth="")
Definition: Mixins.py:629
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 620 of file Mixins.py.

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

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