Ejemplo n.º 1
0
def test_union_of_disjoint():
    first = IntervalSet((i.open(1, 5), i.closed(7, 10)))
    second = IntervalSet((i.open(12, 21), i.closed(22, 23)))
    expected = IntervalSet(
        (i.open(1, 5), i.closed(7, 10), i.open(12, 21), i.closed(22, 23)))
    result = first.union(second)
    assert result == expected
Ejemplo n.º 2
0
def test_union_of_overlapping():
    first = IntervalSet((i.open(1, 5), i.closed(7, 10)))
    second = IntervalSet((i.open(8, 21), i.closed(22, 23)))
    expected = IntervalSet((i.open(1, 5), i.closedopen(7,
                                                       21), i.closed(22, 23)))
    result = first.union(second)
    assert result == expected
Ejemplo n.º 3
0
def test_union_of_equal():
    first = IntervalSet((i.open(1, 5), i.closed(7, 10)))
    result = first.union(first)
    assert result == first
Ejemplo n.º 4
0
def test_union_of_disjoint():
    first = IntervalSet((i.open(1, 5), i.closed(7, 10)))
    second = IntervalSet((i.open(12, 21), i.closed(22,23)))
    expected = IntervalSet((i.open(1, 5), i.closed(7, 10), i.open(12, 21), i.closed(22, 23)))
    result = first.union(second)
    assert result == expected
Ejemplo n.º 5
0
def test_union_of_overlapping():
    first = IntervalSet((i.open(1, 5), i.closed(7, 10)))
    second = IntervalSet((i.open(8, 21), i.closed(22,23)))
    expected = IntervalSet((i.open(1, 5), i.closedopen(7, 21), i.closed(22, 23)))
    result = first.union(second)
    assert result == expected
Ejemplo n.º 6
0
def test_length_of_unioned():
    first = IntervalSet((i.open(1, 5), i.closed(7, 10)))
    second = IntervalSet((i.open(8, 21), i.closed(22,23)))
    # This is of length 3 as 2 of the intervals overlap and therefore join together
    assert len(first.union(second)) == 3
Ejemplo n.º 7
0
def test_union_is_symmetric():  # check expected result and symmetric property
    expected = IntervalSet((i.open(1, 2), i.open(4, 7), i.open(12, 13)))
    first = IntervalSet((i.open(1, 2), i.open(4, 6)))
    second = IntervalSet((i.open(5, 7), i.open(12, 13)))
    assert first.union(second) == expected
    assert second.union(first) == expected
Ejemplo n.º 8
0
def test_union_is_symmetric():  # check expected result and symmetric property
    expected = IntervalSet((i.open(1, 2), i.open(4, 7), i.open(12, 13)))
    first = IntervalSet((i.open(1, 2), i.open(4, 6)))
    second = IntervalSet((i.open(5, 7), i.open(12, 13)))
    assert first.union(second) == expected
    assert second.union(first) == expected
Ejemplo n.º 9
0
def test_length_of_unioned():
    first = IntervalSet((i.open(1, 5), i.closed(7, 10)))
    second = IntervalSet((i.open(8, 21), i.closed(22, 23)))
    # This is of length 3 as 2 of the intervals overlap and therefore join together
    assert len(first.union(second)) == 3
Ejemplo n.º 10
0
def test_union_of_equal():
    first = IntervalSet((i.open(1, 5), i.closed(7, 10)))
    result = first.union(first)
    assert result == first