Belle II Software light-2406-ragdoll
TestIoVSet Class Reference
Inheritance diagram for TestIoVSet:
Collaboration diagram for TestIoVSet:

Public Member Functions

def test_add (self)
 
def test_remove (self)
 
def test_intersection (self)
 

Detailed Description

Helper class to test a set of IoVs

Definition at line 122 of file test_iov.py.

Member Function Documentation

◆ test_add()

def test_add (   self)
Test adding iovs to a set

Definition at line 125 of file test_iov.py.

125 def test_add(self):
126 """Test adding iovs to a set"""
127 inputs = [
128 [(0, 0, 0, -1), (1, 0, 1, -1), (2, 1, 2, -1), (3, 1, 3, 1), (3, 2, 3, 2), (3, 3, 3, 6), (3, 8, 3, 8)],
129 [(0, i, 0, i) for i in range(0, 100)],
130 [(0, i, 0, i) for i in range(0, 100, 2)],
131 ]
132 results = [
133 [(0, 0, 1, -1), (2, 1, 2, -1), (3, 1, 3, 6), (3, 8, 3, 8)],
134 [(0, 0, 0, 99)],
135 [(0, i, 0, i) for i in range(0, 100, 2)],
136 ]
137
138 for _ in range(10):
139 for input, output in zip(inputs, results):
140 s = IoVSet()
141 for iov in random.sample(input, len(input)):
142 s.add(iov)
143 output = {IntervalOfValidity(e) for e in output}
144 self.assertEqual(s.iovs, output)
145

◆ test_intersection()

def test_intersection (   self)
Test intersecting two sets

Definition at line 158 of file test_iov.py.

158 def test_intersection(self):
159 """Test intersecting two sets"""
160 iovs = []
161 for i in range(6):
162 iovs.append((i, 0, i + 5, -1))
163 result = {IntervalOfValidity(5, 0, 5, -1)}
164 for _ in range(10):
165 a = IoVSet([IntervalOfValidity.always()])
166 for iov in random.sample(iovs, len(iovs)):
167 a = a.intersect(iov)
168 self.assertEqual(a.iovs, result)
169 full = IoVSet(iovs, allow_overlaps=True)
170 self.assertEqual(full.iovs, {IntervalOfValidity(0, 0, 10, -1)})
171
172

◆ test_remove()

def test_remove (   self)
Test removing iovs from a set

Definition at line 146 of file test_iov.py.

146 def test_remove(self):
147 """Test removing iovs from a set"""
148 s = IoVSet()
149 s.add((0, 0, 0, 100))
150 to_remove = [(0, i, 0, i) for i in range(0, 100, 2)]
151 result = {IntervalOfValidity(0, i, 0, i) for i in range(1, 99, 2)}
152 result.add(IntervalOfValidity(0, 99, 0, 100))
153 for _ in range(10):
154 for iov in random.sample(to_remove, len(to_remove)):
155 s.remove(iov)
156 self.assertEqual(s.iovs, result)
157

The documentation for this class was generated from the following file: