|
def | __init__ (self, *args, **kwargs) |
|
def | logical_not (self) |
|
def | logical_or (cls, *rhs_iovsets) |
|
def | logical_and (cls, *rhs_iovsets) |
|
def | __or__ (self, rhs) |
|
def | __and__ (self, rhs) |
|
def | from_iovsets (cls, iovsets) |
|
def | connect_adjacent (self) |
|
def | pprint (self, where=stdout) |
|
def | ordered (self) |
|
def | to_file (self, filename) |
|
def | from_file (cls, filename) |
|
def | from_grl_string (cls, data) |
|
def | from_grl (cls, filename) |
|
def | to_grl_string (self, name="unknown", version="unknown") |
|
def | to_grl (self, filename, name="unknown", version="unknown") |
|
def | from_runs (cls, runs) |
|
def | chans_iovsets (self) |
|
def | empty (self, content=None) |
|
def | empty_maker (self) |
|
def | __reduce__ (self) |
|
def | __hash__ (self) |
|
def | __repr__ (self) |
|
def | add (self, since, until, *args) |
|
def | solidify (self, iov_type) |
|
def | trim_iovs (self) |
|
def | add_old (self, iov) |
|
def | time_based (self) |
|
def | lb_counts (self) |
|
def | duration (self) |
|
def | __getslice__ (self, *args) |
|
def | runs (self) |
|
def | by_run (self) |
|
def | channels (self) |
|
def | by_channel (self) |
|
def | first (self) |
|
def | last (self) |
|
def | range_iov (self) |
|
def | intersect_range (self, iov_range) |
|
def | select_runs (self, *selected) |
|
def | select_channels (self, *selected) |
|
def | select (self, **what) |
|
Definition at line 23 of file iovset.py.
◆ __init__()
def python.sugar.iovset.IOVSet.__init__ |
( |
|
self, |
|
|
* |
args, |
|
|
** |
kwargs |
|
) |
| |
Definition at line 24 of file iovset.py.
25 self.iov_type = kwargs.pop(
"iov_type",
None)
26 self.origin = kwargs.pop(
"origin",
None)
27 self.parent = kwargs.pop(
"parent",
None)
28 from sys
import _getframe
30 self.constructed_at =
"%s:%i" % (f.f_code.co_filename, f.f_lineno)
31 super(IOVSet, self).
__init__(*args, **kwargs)
32 if self.iov_type
is None and self:
33 self.iov_type =
type(self.first)
◆ __and__()
def python.sugar.iovset.IOVSet.__and__ |
( |
|
self, |
|
|
|
rhs |
|
) |
| |
Definition at line 73 of file iovset.py.
73 def __and__(self, rhs):
75 return self.logical_and(self, rhs)
◆ __getslice__()
def python.sugar.iovset.IOVSet.__getslice__ |
( |
|
self, |
|
|
* |
args |
|
) |
| |
Slicing an IOVSet should return an IOVSet
Definition at line 269 of file iovset.py.
269 def __getslice__(self, *args):
271 Slicing an IOVSet should return an IOVSet
273 return self.__class__(super(IOVSet, self).__getslice__(*args))
◆ __hash__()
def python.sugar.iovset.IOVSet.__hash__ |
( |
|
self | ) |
|
◆ __or__()
def python.sugar.iovset.IOVSet.__or__ |
( |
|
self, |
|
|
|
rhs |
|
) |
| |
Definition at line 69 of file iovset.py.
69 def __or__(self, rhs):
71 return self.logical_or(self, rhs)
◆ __reduce__()
def python.sugar.iovset.IOVSet.__reduce__ |
( |
|
self | ) |
|
Make an IOVSet pickleable (beware limitations)
Definition at line 172 of file iovset.py.
172 def __reduce__(self):
174 Make an IOVSet pickleable (beware limitations)
176 types =
set(
type(x)
for x
in self)
180 assert len(types) == 1, (
181 "Can only pickle IOVSets with only one type (got types=%r)" % types)
183 iov_type =
type(self.first)
184 name = iov_type.__name__
185 variables = iov_type._fields[2:]
187 return restore_iovset, (
type(self), name, variables, map(tuple, self))
◆ __repr__()
def python.sugar.iovset.IOVSet.__repr__ |
( |
|
self | ) |
|
Definition at line 192 of file iovset.py.
194 args = (len(self), self.duration, len(self.channels),
195 (
"%.2f" % (self.duration / len(self.channels)))
196 if self.channels
else "N/A")
197 plurals = [
"" if x == 1
else "s" for x
in args]
199 return (
"<%i IoV%s %.2f hour%s %i channel%s (avg=%s hr%s/c)>"
202 args = len(self), self.lb_counts, len(self.runs), len(self.channels)
203 plurals = [
"" if x == 1
else "s" for x
in args]
205 return "<%i IoV%s %i lb%s %i run%s %i channel%s>" % args
◆ add()
def python.sugar.iovset.IOVSet.add |
( |
|
self, |
|
|
|
since, |
|
|
|
until, |
|
|
* |
args |
|
) |
| |
Definition at line 207 of file iovset.py.
207 def add(self, since, until, *args):
209 if self
and self[-1][1] == since
and self[-1][2:] == args:
214 self.append([since, until] + args)
◆ add_old()
def python.sugar.iovset.IOVSet.add_old |
( |
|
self, |
|
|
|
iov |
|
) |
| |
Extends this result set by one iov. If it is adjacent (and equal)
to the previous IoV, then that IoV is extended instead.
This was deprecated because it is too slow compared to add() and solidify().
Definition at line 231 of file iovset.py.
231 def add_old(self, iov):
233 Extends this result set by one iov. If it is adjacent (and equal)
234 to the previous IoV, then that IoV is extended instead.
236 This was deprecated because it is too slow compared to add() and solidify().
238 if self
and self.last.connected_to(iov):
239 self[-1] = self[-1].
merge(iov)
◆ by_channel()
def python.sugar.iovset.IOVSet.by_channel |
( |
|
self | ) |
|
Return a dictionary representing {channels : iovs with channelid}
Definition at line 302 of file iovset.py.
302 def by_channel(self):
304 Return a dictionary representing {channels : iovs with channelid}
307 from ..iov_arrangement
import split_by_channel
◆ by_run()
def python.sugar.iovset.IOVSet.by_run |
( |
|
self | ) |
|
Return a dictionary representing {run : iovs in run}
Definition at line 283 of file iovset.py.
285 Return a dictionary representing {run : iovs in run}
287 result = defaultdict(IOVSet)
289 result[iov.run].
append(iov)
◆ channels()
def python.sugar.iovset.IOVSet.channels |
( |
|
self | ) |
|
The set of channels this IOVSet represents
Definition at line 293 of file iovset.py.
295 The set of channels this IOVSet represents
297 if not self
or not hasattr(self[0],
"channel"):
299 return set(iov.channel
for iov
in self)
◆ chans_iovsets()
def python.sugar.iovset.IOVSet.chans_iovsets |
( |
|
self | ) |
|
Returns ([channel1, c2, c3, ...], [channel 1 iovs, c2iovs, c3iovs, ...])
Definition at line 145 of file iovset.py.
145 def chans_iovsets(self):
147 Returns ([channel1, c2, c3, ...], [channel 1 iovs, c2iovs, c3iovs, ...])
◆ connect_adjacent()
def python.sugar.iovset.IOVSet.connect_adjacent |
( |
|
self | ) |
|
Definition at line 92 of file iovset.py.
92 def connect_adjacent(self):
93 from ..iov_arrangement
import connect_adjacent_iovs
◆ duration()
def python.sugar.iovset.IOVSet.duration |
( |
|
self | ) |
|
Duration of the sum of the time-based IoVs, in hours.
Definition at line 263 of file iovset.py.
265 Duration of the sum of the time-based IoVs, in hours.
267 return self.lb_counts / 1e9 / 3600
◆ empty()
def python.sugar.iovset.IOVSet.empty |
( |
|
self, |
|
|
|
content = None |
|
) |
| |
Return an empty IOVSet, but keeping any metadata around. (Such as the
IOVType we were holding..)
Definition at line 153 of file iovset.py.
153 def empty(self, content=None):
155 Return an empty IOVSet, but keeping any metadata around. (Such as the
156 IOVType we were holding..)
158 return self.empty_maker()([]
if content
is None else content)
◆ empty_maker()
def python.sugar.iovset.IOVSet.empty_maker |
( |
|
self | ) |
|
Indirection is used here in order to create new empty instances on
demand without keeping a reference to the original object alive.
Definition at line 160 of file iovset.py.
160 def empty_maker(self):
162 Indirection is used here in order to create new empty instances on
163 demand without keeping a reference to the original object alive.
165 iov_type = self.iov_type
167 def empty(content=None):
168 return type(self)([]
if content
is None else content,
169 iov_type=iov_type, origin=origin, parent=self)
◆ first()
def python.sugar.iovset.IOVSet.first |
( |
|
self | ) |
|
Definition at line 311 of file iovset.py.
312 "The first IoV in the set"
313 assert self, (
".first used in an empty IoV set. Is the range you are "
314 "trying to query valid?")
◆ from_file()
def python.sugar.iovset.IOVSet.from_file |
( |
|
cls, |
|
|
|
filename |
|
) |
| |
Definition at line 115 of file iovset.py.
115 def from_file(cls, filename):
116 with open(filename,
"rb")
as fd:
117 if filename.endswith(
".bz2"):
118 return loads(fd.read().
decode(
"bz2"))
◆ from_grl()
def python.sugar.iovset.IOVSet.from_grl |
( |
|
cls, |
|
|
|
filename |
|
) |
| |
Definition at line 127 of file iovset.py.
127 def from_grl(cls, filename):
128 with open(filename,
"rb")
as fd:
129 return cls.from_grl_string(fd.read())
◆ from_grl_string()
def python.sugar.iovset.IOVSet.from_grl_string |
( |
|
cls, |
|
|
|
data |
|
) |
| |
Definition at line 122 of file iovset.py.
122 def from_grl_string(cls, data):
123 from ..grl
import load_grl_string
◆ from_iovsets()
def python.sugar.iovset.IOVSet.from_iovsets |
( |
|
cls, |
|
|
|
iovsets |
|
) |
| |
Construct one IOVSet from many iovsets
Definition at line 78 of file iovset.py.
78 def from_iovsets(cls, iovsets):
80 Construct one IOVSet from many iovsets
82 iovsets =
list(iovsets)
85 types =
set(iovset.iov_type
for iovset
in iovsets)
86 assert len(types) == 1
87 origins = [i.origin
for i
in iovsets]
88 parents = [i.parent
for i
in iovsets]
89 iov_gen = (iov
for iovset
in iovsets
for iov
in iovset)
90 return cls(iov_gen, iov_type=types.pop(), origin=origins, parent=parents)
◆ from_runs()
def python.sugar.iovset.IOVSet.from_runs |
( |
|
cls, |
|
|
|
runs |
|
) |
| |
Definition at line 140 of file iovset.py.
140 def from_runs(cls, runs):
◆ intersect_range()
def python.sugar.iovset.IOVSet.intersect_range |
( |
|
self, |
|
|
|
iov_range |
|
) |
| |
Returns a new IOVSet intersected with `iov_range` (since, until)
Definition at line 334 of file iovset.py.
334 def intersect_range(self, iov_range):
336 Returns a new IOVSet intersected with `iov_range` (since, until)
338 since, until = iov_range
341 intersected = (iov.intersect(iov_range)
for iov
in self)
342 return self.empty(iov
for iov
in intersected
if iov)
◆ last()
def python.sugar.iovset.IOVSet.last |
( |
|
self | ) |
|
Definition at line 318 of file iovset.py.
319 "The last IoV in the set"
320 assert self, (
".last used in an empty IoV set. Is the range you are "
321 "trying to query valid?")
◆ lb_counts()
def python.sugar.iovset.IOVSet.lb_counts |
( |
|
self | ) |
|
Sum of the LB counts
Definition at line 256 of file iovset.py.
260 return sum(iov.length
for iov
in self)
◆ logical_and()
def python.sugar.iovset.IOVSet.logical_and |
( |
|
cls, |
|
|
* |
rhs_iovsets |
|
) |
| |
Gives the IOV ranges which are present in both this IOVSet and `rhs`
Definition at line 57 of file iovset.py.
57 def logical_and(cls, *rhs_iovsets):
59 Gives the IOV ranges which are present in both this IOVSet and `rhs`
62 from ..events
import process_iovs
66 result.add(since, until)
67 return result.solidify(RANGEIOV_VAL)
◆ logical_not()
def python.sugar.iovset.IOVSet.logical_not |
( |
|
self | ) |
|
Definition at line 35 of file iovset.py.
35 def logical_not(self):
36 from ..events
import process_iovs
41 for since, until, (_, state)
in events
if not state)
◆ logical_or()
def python.sugar.iovset.IOVSet.logical_or |
( |
|
cls, |
|
|
* |
rhs_iovsets |
|
) |
| |
Gives the IOV ranges which are present in both this IOVSet and `rhs`
Definition at line 44 of file iovset.py.
44 def logical_or(cls, *rhs_iovsets):
46 Gives the IOV ranges which are present in both this IOVSet and `rhs`
49 from ..events
import process_iovs
53 result.add(since, until)
54 return result.solidify(RANGEIOV_VAL)
◆ ordered()
def python.sugar.iovset.IOVSet.ordered |
( |
|
self | ) |
|
Definition at line 100 of file iovset.py.
103 if iov.since > iov.until:
105 if prev_until
is not None and iov.since < prev_until:
107 prev_until = iov.until
◆ pprint()
def python.sugar.iovset.IOVSet.pprint |
( |
|
self, |
|
|
|
where = stdout |
|
) |
| |
Definition at line 96 of file iovset.py.
96 def pprint(self, where=stdout):
◆ range_iov()
def python.sugar.iovset.IOVSet.range_iov |
( |
|
self | ) |
|
Returns an IoV object which represents the maximum range contained by
the IoVs.
Definition at line 325 of file iovset.py.
327 Returns an IoV object which represents the maximum range contained by
330 since =
min(i.since
for i
in self)
331 until =
max(i.until
for i
in self)
◆ runs()
def python.sugar.iovset.IOVSet.runs |
( |
|
self | ) |
|
The set of runs present in this IOVSet
Definition at line 276 of file iovset.py.
278 The set of runs present in this IOVSet
280 return set(iov.since.run
for iov
in self)
◆ select()
def python.sugar.iovset.IOVSet.select |
( |
|
self, |
|
|
** |
what |
|
) |
| |
Definition at line 359 of file iovset.py.
361 return all(getattr(iov, key) == value
362 for key, value
in what.iteritems())
364 return self.empty(iov
for iov
in self
if selected(iov))
◆ select_channels()
def python.sugar.iovset.IOVSet.select_channels |
( |
|
self, |
|
|
* |
selected |
|
) |
| |
Pick IoVs which are in the set of channels `selected`
Definition at line 352 of file iovset.py.
352 def select_channels(self, *selected):
354 Pick IoVs which are in the set of channels `selected`
356 selected =
set(selected)
357 return self.empty(iov
for iov
in self
if iov.channel
in selected)
◆ select_runs()
def python.sugar.iovset.IOVSet.select_runs |
( |
|
self, |
|
|
* |
selected |
|
) |
| |
Pick IoVs which are in the set of runs `selected`
Definition at line 344 of file iovset.py.
344 def select_runs(self, *selected):
346 Pick IoVs which are in the set of runs `selected`
348 selected =
set(selected)
349 return self.empty(iov
for iov
in self
350 if any(run
in selected
for run
in iov.runs))
◆ solidify()
def python.sugar.iovset.IOVSet.solidify |
( |
|
self, |
|
|
|
iov_type |
|
) |
| |
Because mutating lists is faster, once building an IOVSet is complete,
it should be 'solidified' into the desired IOV type
Definition at line 216 of file iovset.py.
216 def solidify(self, iov_type):
218 Because mutating lists is faster, once building an IOVSet is complete,
219 it should be 'solidified' into the desired IOV type
222 return IOVSet(map(iov_type._make, self))
◆ time_based()
def python.sugar.iovset.IOVSet.time_based |
( |
|
self | ) |
|
Looks at the first IoV to see if it is time based
Definition at line 244 of file iovset.py.
244 def time_based(self):
246 Looks at the first IoV to see if it is time based
251 return self.first.is_time_based
252 except AttributeError:
◆ to_file()
def python.sugar.iovset.IOVSet.to_file |
( |
|
self, |
|
|
|
filename |
|
) |
| |
Definition at line 110 of file iovset.py.
110 def to_file(self, filename):
111 with open(filename,
"wb")
as fd:
◆ to_grl()
def python.sugar.iovset.IOVSet.to_grl |
( |
|
self, |
|
|
|
filename, |
|
|
|
name = "unknown" , |
|
|
|
version = "unknown" |
|
) |
| |
Definition at line 135 of file iovset.py.
135 def to_grl(self, filename, name="unknown", version="unknown"):
136 with open(filename,
"w")
as fd:
137 fd.write(self.to_grl_string(name, version))
◆ to_grl_string()
def python.sugar.iovset.IOVSet.to_grl_string |
( |
|
self, |
|
|
|
name = "unknown" , |
|
|
|
version = "unknown" |
|
) |
| |
Definition at line 131 of file iovset.py.
131 def to_grl_string(self, name="unknown", version="unknown"):
132 from ..grl
import make_grl
133 return make_grl(self, name, version)
◆ trim_iovs()
def python.sugar.iovset.IOVSet.trim_iovs |
( |
|
self | ) |
|
Ensure all IoVs start on lumiblock 1.
Definition at line 225 of file iovset.py.
227 Ensure all IoVs start on lumiblock 1.
229 return self.empty(iov.trimmed
for iov
in self)
◆ constructed_at
python.sugar.iovset.IOVSet.constructed_at |
◆ iov_type
python.sugar.iovset.IOVSet.iov_type |
◆ origin
python.sugar.iovset.IOVSet.origin |
◆ parent
python.sugar.iovset.IOVSet.parent |
The documentation for this class was generated from the following file:
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.