def test_interval_union_intersection_1(): iu1 = IntervalUnion([[0, 100]]) iu2 = IntervalUnion([[1, 2]]) iu3 = iu1.intersection(iu2) iu4 = iu1 & iu2 assert iu3.intervals == [Interval(1, 2)] assert iu3 == iu4
def test_interval_union_intersection_error(): iu1 = IntervalUnion([[0, 10], [20, 30], [40, 50]]) iu2 = [[-1, 60]] with pytest.raises(RuntimeError) as exinfo: iu1.intersection(iu2) assert str(exinfo.value) == "Intersection with type=<class 'list'> not supported"
def test_interval_union_intersection(): iu1 = IntervalUnion([[0, 10], [20, 30], [40, 50]]) iu2 = IntervalUnion([[-1, 60]]) iu3 = iu1.intersection(iu2) expected_intervals = [Interval(0, 10), Interval(20, 30), Interval(40, 50)] assert iu3.intervals == expected_intervals
def test_interval_union_intersection_3(): iu1 = IntervalUnion([[0, 10], [20, 30], [40, 50]]) iu2 = IntervalUnion([[10, 20]]) iu3 = iu1.intersection(iu2) assert iu3.intervals == [Interval(10, 10), Interval(20, 20)]
def test_interval_union_intersection_2(): iu1 = IntervalUnion([[0, 10], [20, 30], [40, 50]]) iu2 = IntervalUnion([[5, 25], [45, 60]]) iu3 = iu1.intersection(iu2) iu_expected = [Interval(5, 10), Interval(20, 25), Interval(45, 50)] assert iu3.intervals == iu_expected