Belle II Software development
|
Public Member Functions | |
def | __init__ (self, iterable=None, *allow_overlaps=False, allow_startone=False) |
def | add (self, iov, allow_overlaps=None) |
def | remove (self, iov) |
def | intersect (self, iov) |
def | contains (self, iov) |
def | overlaps (self, iov) |
def | copy (self) |
def | clear (self) |
def | iovs (self) |
def | first (self) |
def | final (self) |
def | gaps (self) |
def | __bool__ (self) |
def | __contains__ (self, iov) |
def | __and__ (self, other) |
def | __or__ (self, other) |
def | __sub__ (self, other) |
def | __iter__ (self) |
def | __len__ (self) |
def | __repr__ (self) |
Private Attributes | |
__iovs | |
The set of iovs. | |
__allow_overlaps | |
Whether or not we raise an error on overlaps. | |
__allow_startone | |
Whether or not run 1 will be also considered the first run when combining iovs between experiments. | |
A set of iovs. This class allows to combine iovs into a set. New iovs can be added with `add()` and will be combined with existing iovs if possible. The final, minimal number of iovs can be obtained with the `iovs` property >>> a = IoVSet() >>> a.add((0,0,0,2)) >>> a.add((0,3,0,5)) >>> a.add((0,8,0,9)) >>> a {(0, 0, 0, 5), (0, 8, 0, 9)}
def __init__ | ( | self, | |
iterable = None , |
|||
* | allow_overlaps = False , |
||
allow_startone = False |
|||
) |
Create a new set. >>> a = IoVSet([IntervalOfValidity(3,6,3,-1), (0,0,3,5)]) >>> a {(0, 0, 3, inf)} Parameters: iterable: if not None it should be an iterable of IntervalOfValidity objects or anything that can be converted to an IntervalOfValidity. allow_overlaps (bool): If False adding which overlaps with any existing iov in the set will raise a ValueError. allow_startone (bool): If True also join iovs if one covers the whole experiment and the next one starts at run 1 in the next experiment. If False they will only be joined if the next one starts at run 0.
Definition at line 295 of file iov.py.
def __and__ | ( | self, | |
other | |||
) |
Return a new set that is the intersection between two sets >>> a = IoVSet([(0,0,1,-1)]) >>> a & (1,0,2,-1) {(1, 0, 1, inf)}
Definition at line 622 of file iov.py.
def __bool__ | ( | self | ) |
Return True if the set is not empty >>> a = IoVSet() >>> a.add((0,0,1,-1)) >>> bool(a) True >>> a.clear() >>> a {} >>> bool(a) False
Definition at line 602 of file iov.py.
def __contains__ | ( | self, | |
iov | |||
) |
def __iter__ | ( | self | ) |
def __len__ | ( | self | ) |
def __or__ | ( | self, | |
other | |||
) |
Return a new set that is the combination of two sets: The new set will be valid everywhere any of the two sets were valid. No check for overlaps will be performed but the result will inherit the settings for further additions from the first set >>> a = IoVSet([(0,0,1,-1)]) >>> a | (1,0,2,-1) {(0, 0, 2, inf)} >>> a | (3,0,3,-1) {(0, 0, 1, inf), (3, 0, 3, inf)}
Definition at line 631 of file iov.py.
def __repr__ | ( | self | ) |
def __sub__ | ( | self, | |
other | |||
) |
Return a new set which is only valid for where a is valid but not b. See `remove` but this will not modify the set in place >>> a = IoVSet([(0,0,-1,-1)]) >>> a - (1,0,2,-1) {(0, 0, 0, inf), (3, 0, inf, inf)} >>> a - (0,0,3,-1) - (10,0,-1,-1) {(4, 0, 9, inf)} >>> IoVSet([(0,0,1,-1)]) - (2,0,2,-1) {(0, 0, 1, inf)}
Definition at line 649 of file iov.py.
def add | ( | self, | |
iov, | |||
allow_overlaps = None |
|||
) |
Add a new iov to the set. The new iov be combined with existing iovs if possible. After the operation the set will contain the minimal amount of separate iovs possible to represent all added iovs >>> a = IoVSet() >>> a.add((0, 0, 0, 2)) >>> a.add((0, 3, 0, 5)) >>> a.add((0, 8, 0, 9)) >>> a {(0, 0, 0, 5), (0, 8, 0, 9)} >>> a.add(IoVSet([(10, 0, 10, 1), (10, 2, 10, -1)])) >>> a {(0, 0, 0, 5), (0, 8, 0, 9), (10, 0, 10, inf)} Be aware, by default it's not possible to add overlapping iovs to the set. This can be changed either on construction or per `add` call using ``allow_overlap`` >>> a.add((0, 2, 0, 3)) Traceback (most recent call last): ... ValueError: Overlap between (0, 0, 0, 5) and (0, 2, 0, 3) >>> a.add((0, 2, 0, 3), allow_overlaps=True) >>> a {(0, 0, 0, 5), (0, 8, 0, 9), (10, 0, 10, inf)} Parameters: iov (Union[IoVSet, IntervalOfValidity, tuple(int)]): IoV or set of IoVs to add to this set allow_overlaps (bool): Can be used to override global overlap setting of this set to allow/restrict overlaps for a single insertion operation Warning: This method modifies the set in place
Definition at line 323 of file iov.py.
def clear | ( | self | ) |
def contains | ( | self, | |
iov | |||
) |
Check if an iov is fully covered by the set >>> a = IoVSet([(0,0,2,-1), (5,0,5,-1)]) >>> a.contains((0,0,1,-1)) True >>> a.contains(IntervalOfValidity(0,0,3,2)) False >>> a.contains(IoVSet([(0,1,1,23), (5,0,5,23)])) True >>> a.contains(IoVSet([(0,1,1,23), (5,0,6,23)])) False >>> a.contains((3,0,4,-1)) False Parameters: iov (Union[IoVSet, IntervalOfValidity, tuple(int)]): IoV or set of IoVs to be checked Returns: True if the full iov or all the iovs in the given set are fully present in this set
Definition at line 468 of file iov.py.
def copy | ( | self | ) |
def final | ( | self | ) |
Return the final run covered by this iov set >>> a = IoVSet([(3,0,3,10), (10,11,10,23), (0,0,2,-1), (5,0,5,-1)]) >>> a.final (10, 23)
Definition at line 570 of file iov.py.
def first | ( | self | ) |
Return the first run covered by this iov set >>> a = IoVSet([(3,0,3,10), (10,11,10,23), (0,0,2,-1), (5,0,5,-1)]) >>> a.first (0, 0)
Definition at line 558 of file iov.py.
def gaps | ( | self | ) |
Return the gaps in the set. Any area not covered between the first point of validity and the last >>> a = IoVSet([(0,0,2,-1)]) >>> a.gaps {} >>> b = IoVSet([(0,0,2,-1), (5,0,5,-1)]) >>> b.gaps {(3, 0, 4, inf)} >>> c = IoVSet([(0,0,2,-1), (5,0,5,-1), (10,3,10,6)]) >>> c.gaps {(3, 0, 4, inf), (6, 0, 10, 2)}
Definition at line 582 of file iov.py.
def intersect | ( | self, | |
iov | |||
) |
Intersect this set with another set and return a new set which is valid exactly where both sets have been valid before >>> a = IoVSet() >>> a.add((0,0,10,-1)) >>> a.intersect((5,0,20,-1)) {(5, 0, 10, inf)} >>> a.intersect(IoVSet([(0,0,3,-1), (9,0,20,-1)])) {(0, 0, 3, inf), (9, 0, 10, inf)} Parameters: iov (Union[IoVSet, IntervalOfValidity, tuple(int)]): IoV or set of IoVs to intersect with this set
Definition at line 439 of file iov.py.
def iovs | ( | self | ) |
def overlaps | ( | self, | |
iov | |||
) |
Check if the given iov overlaps with this set. In contrast to `contains` this doesn't require the given iov to be fully covered. It's enough if the any run covered by the iov is also covered by this set. >>> a = IoVSet([(0,0,2,-1), (5,0,5,-1)]) >>> a.overlaps((0,0,1,-1)) True >>> a.overlaps(IntervalOfValidity(0,0,3,2)) True >>> a.overlaps(IoVSet([(0,1,1,23), (5,0,5,23)])) True >>> a.overlaps(IoVSet([(0,1,1,23), (5,0,6,23)])) True >>> a.overlaps((3,0,4,-1)) False Parameters: iov (Union[IoVSet, IntervalOfValidity, tuple(int)]): IoV or set of IoVs to be checked Returns: True if the iov or any of the iovs in the given set overlap with any iov in this set
Definition at line 504 of file iov.py.
def remove | ( | self, | |
iov | |||
) |
Remove an iov or a set of iovs from this set After this operation the set will not be valid for the given iov or set of iovs: >>> a = IoVSet() >>> a.add((0,0,10,-1)) >>> a.remove((1,0,1,-1)) >>> a.remove((5,0,8,5)) >>> a {(0, 0, 0, inf), (2, 0, 4, inf), (8, 6, 10, inf)} >>> a.remove(IoVSet([(3,0,3,10), (3,11,3,-1)])) >>> a {(0, 0, 0, inf), (2, 0, 2, inf), (4, 0, 4, inf), (8, 6, 10, inf)} Parameters: iov (Union[IoVSet, IntervalOfValidity, tuple(int)]): IoV or set of IoVs to remove from this set Warning: This method modifies the set in place
Definition at line 396 of file iov.py.
|
private |
|
private |