|
def | __init__ (self, flags, name, dimensions, **kwargs) |
|
def | __getitem__ (self, index) |
|
def | toolList (self) |
|
def | broadcast (self, member, value) |
|
def | defineHistogram (self, varname, title=None, path=None, pattern=None, **kwargs) |
|
Array of configurables of GenericMonitoringTool objects
Definition at line 61 of file GenericMonitoringTool.py.
◆ __init__()
def GenericMonitoringTool.GenericMonitoringArray.__init__ |
( |
|
self, |
|
|
|
flags, |
|
|
|
name, |
|
|
|
dimensions, |
|
|
** |
kwargs |
|
) |
| |
Definition at line 63 of file GenericMonitoringTool.py.
63 def __init__(self, flags, name, dimensions, **kwargs):
65 self.Postfixes, self.Accessors = GenericMonitoringArray._postfixes(dimensions)
66 for postfix
in self.Postfixes:
◆ __getitem__()
def GenericMonitoringTool.GenericMonitoringArray.__getitem__ |
( |
|
self, |
|
|
|
index |
|
) |
| |
Forward operator[] on class to the list of tools
Definition at line 69 of file GenericMonitoringTool.py.
70 '''Forward operator[] on class to the list of tools'''
71 return self.toolList()[index]
◆ _postfixes()
def GenericMonitoringTool.GenericMonitoringArray._postfixes |
( |
|
dimensions, |
|
|
|
previous = '' |
|
) |
| |
|
staticprivate |
Generates a list of subscripts to add to the name of each tool
Arguments:
dimensions -- List containing the lengths of each side of the array off tools
previous -- Strings appended from the other dimensions of the array
Definition at line 138 of file GenericMonitoringTool.py.
138 def _postfixes(dimensions, previous=''):
139 '''Generates a list of subscripts to add to the name of each tool
142 dimensions -- List containing the lengths of each side of the array off tools
143 previous -- Strings appended from the other dimensions of the array
146 assert isinstance(dimensions,list)
and len(dimensions)>0, \
147 'GenericMonitoringArray must have list of dimensions.'
150 return [
''], {
'': [
'']}
151 except AttributeError:
155 accessorDict = collections.OrderedDict()
156 first = dimensions[0]
157 if isinstance(first,list):
159 elif isinstance(first,int):
160 iterable =
range(first)
163 iterable =
list(first)
165 if len(dimensions)==1:
166 postList.append(previous+
'_'+
str(i))
167 accessorDict[previous+
'_'+
str(i)]=[
str(i)]
169 postfixes, accessors = GenericMonitoringArray._postfixes(dimensions[1:],previous+
'_'+
str(i))
170 postList.extend(postfixes)
171 for acckey, accval
in accessors.items():
172 accessorDict[acckey] = [
str(i)] + accval
173 return postList, accessorDict
◆ broadcast()
def GenericMonitoringTool.GenericMonitoringArray.broadcast |
( |
|
self, |
|
|
|
member, |
|
|
|
value |
|
) |
| |
Allows one to set attributes of every tool simultaneously
Arguments:
member -- string which contains the name of the attribute to be set
value -- value of the attribute to be set
Definition at line 76 of file GenericMonitoringTool.py.
76 def broadcast(self, member, value):
77 '''Allows one to set attributes of every tool simultaneously
80 member -- string which contains the name of the attribute to be set
81 value -- value of the attribute to be set
83 for tool
in self.toolList():
84 setattr(tool,member,value)
◆ defineHistogram()
def GenericMonitoringTool.GenericMonitoringArray.defineHistogram |
( |
|
self, |
|
|
|
varname, |
|
|
|
title = None , |
|
|
|
path = None , |
|
|
|
pattern = None , |
|
|
** |
kwargs |
|
) |
| |
Propogate defineHistogram to each tool, adding a unique tag.
Arguments:
pattern -- if specified, list of n-tuples of indices for plots to create
Definition at line 86 of file GenericMonitoringTool.py.
86 def defineHistogram(self, varname, title=None, path=None, pattern=None, **kwargs):
87 '''Propogate defineHistogram to each tool, adding a unique tag.
90 pattern -- if specified, list of n-tuples of indices for plots to create
92 unAliased = varname.split(
';')[0]
93 _, aliasBase =
_alias(varname)
94 if aliasBase
is None or aliasBase.strip() ==
'':
95 raise ValueError(f
'Unable to define histogram using definition "{varname}" since we cannot determine its name')
96 if pattern
is not None:
100 raise ValueError(
'Argument to GenericMonitoringArray.defineHistogram must be iterable')
101 if not isinstance(pattern, list):
102 pattern =
list(pattern)
103 if len(pattern) == 0:
105 if isinstance(pattern[0], (str, int)):
107 pattern = [(_2,)
for _2
in pattern]
108 for postfix, tool
in self.Tools.
items():
110 accessors = tuple(self.Accessors[postfix])
111 if pattern
is not None:
112 if accessors
not in pattern:
117 aliasBaseFormatted = aliasBase.format(*accessors)
118 if aliasBaseFormatted==aliasBase:
120 aliased = unAliased+
';'+aliasBase+postfix
123 aliased = unAliased+
';'+aliasBaseFormatted
124 if title
is not None:
125 kwargs[
'title'] = title.format(*accessors)
127 kwargs[
'path'] = path.format(*accessors)
128 except IndexError
as e:
129 log.error(
'In title or path template of histogram {0}, too many positional '\
130 'arguments were requested. Title and path templates were "{1}" and "{2}", '\
131 'while only {3} fillers were given: {4}.'.
format(aliasBase, title,\
132 path, len(accessors), accessors))
135 tool.defineHistogram(aliased, **kwargs)
◆ toolList()
def GenericMonitoringTool.GenericMonitoringArray.toolList |
( |
|
self | ) |
|
◆ Accessors
GenericMonitoringTool.GenericMonitoringArray.Accessors |
◆ Tools
GenericMonitoringTool.GenericMonitoringArray.Tools |
The documentation for this class was generated from the following file: