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 newParams.iteritems():
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_()
642  value,errorRaiser,
643  ("%s.%s" if type(key)==str else "%s[%s]")%(keyDepth,key))
644  for k,v in p.iteritems():
645  setattr(pset,k,v)
646  elif isinstance(params[key],_ValidatingParameterListBase):
647  if any(type(k) != int for k in value.keys()):
648  raise TypeError("Attempted to change a list using a dict whose keys are not integers")
649  plist = params[key]
650  if any((k < 0 or k >= len(plist)) for k in value.keys()):
651  raise IndexError("Attempted to set an index which is not in the list")
652  p = dict(enumerate(plist))
654  value,errorRaiser,
655  ("%s.%s" if type(key)==str else "%s[%s]")%(keyDepth,key))
656  for k,v in p.iteritems():
657  plist[k] = v
658  else:
659  raise ValueError("Attempted to change non PSet value "+keyDepth+" using a dictionary")
660  elif isinstance(value,_ParameterTypeBase) or (type(key) == int):
661  params[key] = value
662  else:
663  params[key].setValue(value)
664  else:
665  if isinstance(value,_ParameterTypeBase):
666  params[key]=value
667  else:
668  errorRaiser(key)
669 
670 
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