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

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

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

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

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

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