ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
python.TransformConfig.UniqueList Class Reference
Inheritance diagram for python.TransformConfig.UniqueList:
Collaboration diagram for python.TransformConfig.UniqueList:

Public Member Functions

def __init__ (self, doc, default=None, allowedValues=None)
 
def __get__ (self, instance, owner)
 
def __set__ (self, instance, value)
 
def name (self)
 
def default (self)
 
def doc (self)
 
def help (self)
 
def allowedValues (self)
 

Private Member Functions

def _checkType (self, variableName, value)
 
def _checkValue (self, variableName, value)
 
def _checkAllowedValues (self, variableName, allowedValues)
 
def _attributeName (self, instance)
 
def _setValue (self, variableName, value)
 

Private Attributes

 __name
 
 __doc
 
 __allowed
 
 __default
 

Detailed Description

List with a unique set of entries (duplicates are removed).
List of allowed values are the entries that are allowed in the list.

Definition at line 187 of file TransformConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.TransformConfig.UniqueList.__init__ (   self,
  doc,
  default = None,
  allowedValues = None 
)

Reimplemented from python.TransformConfig.Descriptor.

Reimplemented in python.TransformConfig.ListOfStrings.

Definition at line 190 of file TransformConfig.py.

190  def __init__(self,doc,default=None,allowedValues=None):
191  if default is None: default = [] # trick needed to avoid sharing among instances
192  Descriptor.__init__(self,doc,default,allowedValues)
193 
194 

Member Function Documentation

◆ __get__()

def python.TransformConfig.Descriptor.__get__ (   self,
  instance,
  owner 
)
inherited

Definition at line 35 of file TransformConfig.py.

35  def __get__(self,instance,owner):
36  if instance is None:
37  return self
38  return instance._attributeDictionary().get(self._attributeName(instance),self.__default)
39 
40 

◆ __set__()

def python.TransformConfig.Descriptor.__set__ (   self,
  instance,
  value 
)
inherited

Definition at line 41 of file TransformConfig.py.

41  def __set__(self,instance,value):
42  varName = "%s.%s" % (instance.name(), self.__name) # for error/debug printout
43  # allow None as a value for all types
44  if value is not None:
45  # do value and/or type checking and possibly change type and/or value
46  value = self._checkType(varName,value)
47  value = self._checkValue(varName,value)
48  # Do possible additional actions
49  self._setValue(varName,value)
50  instance._attributeDictionary()[self._attributeName(instance)] = value # store the value
51 
52 

◆ _attributeName()

def python.TransformConfig.Descriptor._attributeName (   self,
  instance 
)
privateinherited

Definition at line 53 of file TransformConfig.py.

53  def _attributeName(self,instance):
54  return '_%s__%s' % (instance.__class__.__name__,self.__name)
55 
56 

◆ _checkAllowedValues()

def python.TransformConfig.UniqueList._checkAllowedValues (   self,
  variableName,
  allowedValues 
)
private

Reimplemented from python.TransformConfig.Descriptor.

Definition at line 229 of file TransformConfig.py.

229  def _checkAllowedValues(self,variableName,allowedValues):
230  # Convert values to list before calling _checkType, and back to entry
231  newAllowed = set() # []
232  for v in allowedValues:
233  newAllowed.add( self._checkType(variableName,[v])[0] )
234  return list( newAllowed )
235 
236 
237 

◆ _checkType()

def python.TransformConfig.UniqueList._checkType (   self,
  variableName,
  value 
)
private
Check that <value> is of type list of tuple, and convert to a list if it is a tuple.

Reimplemented from python.TransformConfig.Descriptor.

Reimplemented in python.TransformConfig.ListOfStrings.

Definition at line 195 of file TransformConfig.py.

195  def _checkType(self,variableName,value):
196  """Check that <value> is of type list of tuple, and convert to a list if it is a tuple."""
197 # # check types
198 # valType = type(value).__name__
199 # if valType != 'list' and valType != 'tuple':
200 # raise TransformConfigError( '%s should be a list or tuple. Got %s instead.' % \
201 # (variableName, valType) )
202 # if valType == 'tuple':
203 # # convert to a list
204 # value = list(value)
205 # return value
206  try:
207  value.__iter__
208  return list( value )
209  except Exception:
210  raise TransformConfigError( '%s should be a list or tuple. Got %s instead.' %
211  ( variableName, type( value ).__name__ ) )
212 
213 

◆ _checkValue()

def python.TransformConfig.UniqueList._checkValue (   self,
  variableName,
  value 
)
private
Private helper function to check the value of <value>. This function is
called after calling _checkType. <value> can therefore be considered to be
of the correct type.
This implementation checks that the value is one of the allowed values (if defined).
This function can be overridden in derived class to do type & additional value checking.
It has to return the value (adapted if needed) if all is OK. It has to raise
a TransformConfigError exception in case of problems.
<variableName> is the name of the variable that is being set and is typically
only used for error messages.

Reimplemented from python.TransformConfig.Descriptor.

Definition at line 214 of file TransformConfig.py.

214  def _checkValue(self,variableName,value):
215  # check that entries are allowed
216  allowed = self.allowedValues()
217  if allowed:
218  for v in value:
219  if v not in allowed:
220  raise TransformConfigError( '%s value %r is not one of %s' %
221  (variableName, value, allowed) )
222  # make entries unique
223  newValue = set() #[]
224  for v in value:
225  newValue.add( v )
226  return list( newValue )
227 
228 

◆ _setValue()

def python.TransformConfig.Descriptor._setValue (   self,
  variableName,
  value 
)
privateinherited
Private helper function which is called when the value of the object is set.
It is called after _checkType() and _checkValue(), so the value can be
assumed to be correct.
This function can be overridden in a derived class, typically to trigger additional action
when the value is set.
In case of error, raise a TransformConfigError exception, otherwise just return.
This implementation does nothing.
<variableName> is the name of the variable that is being set and is typically
only used for error messages.

Definition at line 109 of file TransformConfig.py.

109  def _setValue(self,variableName,value):
110  """Private helper function which is called when the value of the object is set.
111  It is called after _checkType() and _checkValue(), so the value can be
112  assumed to be correct.
113  This function can be overridden in a derived class, typically to trigger additional action
114  when the value is set.
115  In case of error, raise a TransformConfigError exception, otherwise just return.
116  This implementation does nothing.
117  <variableName> is the name of the variable that is being set and is typically
118  only used for error messages."""
119  pass
120 
121 

◆ allowedValues()

def python.TransformConfig.Descriptor.allowedValues (   self)
inherited

Definition at line 79 of file TransformConfig.py.

79  def allowedValues(self):
80  return self.__allowed
81 
82 

◆ default()

def python.TransformConfig.Descriptor.default (   self)
inherited

Definition at line 61 of file TransformConfig.py.

61  def default(self):
62  return self.__default
63 
64 

◆ doc()

def python.TransformConfig.Descriptor.doc (   self)
inherited
The documentation string

Definition at line 65 of file TransformConfig.py.

65  def doc(self):
66  """The documentation string"""
67  return self.__doc
68 
69 

◆ help()

def python.TransformConfig.Descriptor.help (   self)
inherited
The help string: type, documentation and possible values

Definition at line 70 of file TransformConfig.py.

70  def help(self):
71  """The help string: type, documentation and possible values"""
72  hlp = '(%s) %s' % (self.__class__.__name__, self.__doc)
73  if self.__allowed:
74  hlp += '. Possible values: %s' % self.__allowed
75 
76  return hlp
77 
78 

◆ name()

def python.TransformConfig.Descriptor.name (   self)
inherited

Definition at line 57 of file TransformConfig.py.

57  def name(self):
58  return self.__name
59 
60 

Member Data Documentation

◆ __allowed

python.TransformConfig.Descriptor.__allowed
privateinherited

Definition at line 19 of file TransformConfig.py.

◆ __default

python.TransformConfig.Descriptor.__default
privateinherited

Definition at line 33 of file TransformConfig.py.

◆ __doc

python.TransformConfig.Descriptor.__doc
privateinherited

Definition at line 18 of file TransformConfig.py.

◆ __name

python.TransformConfig.Descriptor.__name
privateinherited

Definition at line 17 of file TransformConfig.py.


The documentation for this class was generated from the following file:
python.CaloScaleNoiseConfig.help
help
Definition: CaloScaleNoiseConfig.py:76
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:224
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
python.CaloScaleNoiseConfig.default
default
Definition: CaloScaleNoiseConfig.py:79