ATLAS Offline Software
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
python.trfArgClasses.argSubstepFloat Class Reference

Float substep argument. More...

Inheritance diagram for python.trfArgClasses.argSubstepFloat:
Collaboration diagram for python.trfArgClasses.argSubstepFloat:

Public Member Functions

def __init__ (self, value=None, min=None, max=None, runarg=True, name=None)
 argSubstep constructor More...
 
def prodsysDescription (self)
 
def value (self)
 Return argument value. More...
 
def value (self, value)
 Set argument value. More...
 
def returnMyValue (self, name=None, substep=None, first=False, exe=None)
 Return the value of this substep arg for an executor with the given parameters. More...
 
def isRunarg (self)
 Return runarg status. More...
 
def name (self)
 Name getter. More...
 
def name (self, value)
 Name setter. More...
 
def __str__ (self)
 String conversion of our value. More...
 
def __repr__ (self)
 Repr conversion of our value. More...
 
def __eq__ (self, other)
 Comparison is based on value attribute. More...
 
def __nq__ (self, other)
 
def __lt__ (self, other)
 
def __gt__ (self, other)
 

Public Attributes

 value
 

Private Member Functions

def _parseStringAsSubstep (self, string)
 Parse a string for substep:value format. More...
 

Private Attributes

 _min
 
 _max
 
 _value
 
 _defaultSubstep
 
 _separator
 
 _runarg
 
 _name
 

Detailed Description

Float substep argument.

Definition at line 2264 of file trfArgClasses.py.

Constructor & Destructor Documentation

◆ __init__()

def python.trfArgClasses.argSubstepFloat.__init__ (   self,
  value = None,
  runarg = None,
  name = None,
  defaultSubstep = True,
  separator = None 
)

argSubstep constructor

Parameters
defaultSubstepDefault substep to use when no specific substep has been given - this should be set to first for arguments that apply, by default, to the first executor in the chain (e.g., maxEvents)

Reimplemented from python.trfArgClasses.argSubstep.

Definition at line 2266 of file trfArgClasses.py.

2266  def __init__(self, value=None, min=None, max=None, runarg=True, name=None):
2267  self._min = min
2268  self._max = max
2269  super(argSubstepFloat, self).__init__(value = value, runarg = runarg, name=name)
2270 

Member Function Documentation

◆ __eq__()

def python.trfArgClasses.argument.__eq__ (   self,
  other 
)
inherited

Comparison is based on value attribute.

Definition at line 161 of file trfArgClasses.py.

161  def __eq__(self,other):
162  return self.value == other.value
163 

◆ __gt__()

def python.trfArgClasses.argument.__gt__ (   self,
  other 
)
inherited

Definition at line 170 of file trfArgClasses.py.

170  def __gt__(self, other):
171  return self.value > other.value
172 

◆ __lt__()

def python.trfArgClasses.argument.__lt__ (   self,
  other 
)
inherited

Definition at line 167 of file trfArgClasses.py.

167  def __lt__(self, other):
168  return self.value < other.value
169 

◆ __nq__()

def python.trfArgClasses.argument.__nq__ (   self,
  other 
)
inherited

Definition at line 164 of file trfArgClasses.py.

164  def __nq__(self, other):
165  return self.value != other.value
166 

◆ __repr__()

def python.trfArgClasses.argument.__repr__ (   self)
inherited

Repr conversion of our value.

Reimplemented in python.trfArgClasses.argList.

Definition at line 157 of file trfArgClasses.py.

157  def __repr__(self):
158  return repr(self.value)
159 

◆ __str__()

def python.trfArgClasses.argument.__str__ (   self)
inherited

String conversion of our value.

Reimplemented in python.trfArgClasses.argFile, python.trfArgClasses.argKeyFloatValueList, python.trfArgClasses.argIntList, python.trfArgClasses.argList, and python.trfArgClasses.argString.

Definition at line 153 of file trfArgClasses.py.

153  def __str__(self):
154  return '{0}: Value {1} (isRunArg={2})'.format(self.__class__.__name__, self._value, self._runarg)
155 

◆ _parseStringAsSubstep()

def python.trfArgClasses.argSubstep._parseStringAsSubstep (   self,
  string 
)
privateinherited

Parse a string for substep:value format.

If the string matches the substep specifier regexp then we return the two parts; if not then the substep is returned as self._defaultSubstep, with the entire string passed back as the value

Parameters
stringThe string which should be parsed

Reimplemented in python.trfArgClasses.argSubstepList.

Definition at line 2001 of file trfArgClasses.py.

2001  def _parseStringAsSubstep(self, string):
2002  subStepMatch = re.match(r'([a-zA-Z0-9,]+)' + self._separator + r'(.*)', string)
2003  subStepList = []
2004  if subStepMatch:
2005  subStep = subStepMatch.group(1).split(',')
2006  subStepValue = subStepMatch.group(2)
2007  else:
2008  subStep = [self._defaultSubstep]
2009  subStepValue = string
2010  msg.debug('Parsed {0} as substep {1}, argument {2}'.format(string, subStep, subStepValue))
2011  for step in subStep:
2012  subStepList.append((step, subStepValue))
2013  return subStepList
2014 
2015 

◆ isRunarg()

def python.trfArgClasses.argument.isRunarg (   self)
inherited

Return runarg status.

Definition at line 134 of file trfArgClasses.py.

134  def isRunarg(self):
135  return self._runarg
136 

◆ name() [1/2]

def python.trfArgClasses.argument.name (   self)
inherited

Name getter.

Reimplemented in python.trfArgClasses.argFile.

Definition at line 139 of file trfArgClasses.py.

139  def name(self):
140  return self._name
141 

◆ name() [2/2]

def python.trfArgClasses.argument.name (   self,
  value 
)
inherited

Name setter.

Reimplemented in python.trfArgClasses.argFile.

Definition at line 144 of file trfArgClasses.py.

144  def name(self, value):
145  self._name = value
146 

◆ prodsysDescription()

def python.trfArgClasses.argSubstepFloat.prodsysDescription (   self)

Reimplemented from python.trfArgClasses.argSubstep.

Definition at line 2272 of file trfArgClasses.py.

2272  def prodsysDescription(self):
2273  desc = {'type': 'substep', 'substeptype': 'float', 'separator': self._separator,
2274  'default': self._defaultSubstep}
2275  if self._min:
2276  desc['min'] = self._min
2277  if self._max:
2278  desc['max'] = self._max
2279  return desc
2280 
2281 

◆ returnMyValue()

def python.trfArgClasses.argSubstep.returnMyValue (   self,
  name = None,
  substep = None,
  first = False,
  exe = None 
)
inherited

Return the value of this substep arg for an executor with the given parameters.

Parameters
nameExecutor name
substepExecutor substep nickname
firstBoolean flag set true if this is the first executor in the chain
exeExecutor instance, from which 'name', 'substep' and 'first' can be taken.

Definition at line 2021 of file trfArgClasses.py.

2021  def returnMyValue(self, name=None, substep=None, first=False, exe=None):
2022  if exe:
2023  name = exe.name
2024  substep = exe.substep
2025  first = exe.conf.firstExecutor
2026 
2027  name = commonExecutorStepName(name)
2028 
2029  value = None
2030 
2031  if name in self._value:
2032  value = self._value[name]
2033  elif substep in self._value:
2034  value = self._value[substep]
2035  elif first and 'first' in self._value:
2036  value = self._value['first']
2037  elif 'default' in self._value:
2038  value = self._value['default']
2039 
2040 
2048  if 'all' in self._value:
2049  if value is None:
2050  value = self._value['all']
2051  elif isinstance(value, list):
2052  value = self._value['all'] + value
2053 
2054  msg.debug('From substep argument {myvalue} picked value "{value}" for {name}, {substep}, first={first}'.format(myvalue=self._value, value=value, name=name, substep=substep, first=first))
2055 
2056  return value
2057 

◆ value() [1/2]

def python.trfArgClasses.argSubstepFloat.value (   self)

Return argument value.

Returns
Current value

Reimplemented from python.trfArgClasses.argSubstep.

Definition at line 2284 of file trfArgClasses.py.

2284  def value(self):
2285  return self._value
2286 

◆ value() [2/2]

def python.trfArgClasses.argSubstepFloat.value (   self,
  value 
)

Set argument value.

Note
No conversion or coercion done

Reimplemented from python.trfArgClasses.argSubstep.

Definition at line 2288 of file trfArgClasses.py.

2288  def value(self, value):
2289  msg.debug('Attempting to set argSubstep from {0!s} (type {1}'.format(value, type(value)))
2290  try:
2291  if value is None:
2292  self._value = {}
2293  elif isinstance(value, float):
2294  self._value = {self._defaultSubstep: value}
2295  elif isinstance(value, str):
2296  subStepList = self._parseStringAsSubstep(value)
2297  self._value = dict([(subStep[0], float(subStep[1])) for subStep in subStepList])
2298  elif isinstance(value, (list, tuple)):
2299  # This is a list of strings to parse
2300  self._value = {}
2301  for item in value:
2302  if not isinstance(item, str):
2303  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2304  'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2305  subStepList = self._parseStringAsSubstep(item)
2306  for subStep in subStepList:
2307  self._value[subStep[0]] = float(subStep[1])
2308  elif isinstance(value, dict):
2309  for k, v in value.items():
2310  if not isinstance(k, str):
2311  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2312  'Dictionary key {0!s} for substep is not a string'.format(k))
2313  if not isinstance(v, float):
2314  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2315  'Dictionary value {0!s} for substep is not an float'.format(v))
2316  self._value = value
2317  else:
2318  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2319  'Setter value {0!s} (type {1}) for substep argument cannot be parsed'.format(value, type(value)))
2320  # Now do min/max checks
2321  for my_float in self._value.values():
2322  if (self._min is not None and my_float < self._min) or (self._max is not None and my_float > self._max):
2323  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_OUT_OF_RANGE'),
2324  'argFloat value out of range: {0} is not between {1} and {2}'.format(my_float, self._min, self._max))
2325  except ValueError as e:
2326  raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2327  'Failed to convert substep value {0} to float: {1}'.format(value, e))
2328 
2329 

Member Data Documentation

◆ _defaultSubstep

python.trfArgClasses.argSubstep._defaultSubstep
privateinherited

Definition at line 1966 of file trfArgClasses.py.

◆ _max

python.trfArgClasses.argSubstepFloat._max
private

Definition at line 2268 of file trfArgClasses.py.

◆ _min

python.trfArgClasses.argSubstepFloat._min
private

Definition at line 2267 of file trfArgClasses.py.

◆ _name

python.trfArgClasses.argument._name
privateinherited

Definition at line 111 of file trfArgClasses.py.

◆ _runarg

python.trfArgClasses.argument._runarg
privateinherited

Definition at line 110 of file trfArgClasses.py.

◆ _separator

python.trfArgClasses.argSubstep._separator
privateinherited

Definition at line 1967 of file trfArgClasses.py.

◆ _value

python.trfArgClasses.argSubstepFloat._value
private

Definition at line 2292 of file trfArgClasses.py.

◆ value

python.trfArgClasses.argument.value
inherited
Note
We have a default of None here, but all derived classes should definitely have their own value setter and translate this value to something sensible for their underlying value type. N.B. As most argument classes use this default constructor it must call the @value .setter function!

Definition at line 118 of file trfArgClasses.py.


The documentation for this class was generated from the following file:
vtune_athena.format
format
Definition: vtune_athena.py:14
athena.value
value
Definition: athena.py:124
python.processes.powheg.ZZj_MiNNLO.ZZj_MiNNLO.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZj_MiNNLO.py:18
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:808
PyAthena::repr
std::string repr(PyObject *o)
returns the string representation of a python object equivalent of calling repr(o) in python
Definition: PyAthenaUtils.cxx:106
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
python.trfExeStepTools.commonExecutorStepName
def commonExecutorStepName(name)
Definition: trfExeStepTools.py:7
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65