コード例 #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
コード例 #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
コード例 #3
0
ファイル: test_interval_set.py プロジェクト: dimonb/pyinter
def test_union_of_equal():
    first = IntervalSet((i.open(1, 5), i.closed(7, 10)))
    result = first.union(first)
    assert result == first
コード例 #4
0
ファイル: test_interval_set.py プロジェクト: dimonb/pyinter
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
コード例 #5
0
ファイル: test_interval_set.py プロジェクト: dimonb/pyinter
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
コード例 #6
0
ファイル: test_interval_set.py プロジェクト: dimonb/pyinter
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
コード例 #7
0
ファイル: test_interval_set.py プロジェクト: Shopify/pyinter
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
コード例 #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
コード例 #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
コード例 #10
0
def test_union_of_equal():
    first = IntervalSet((i.open(1, 5), i.closed(7, 10)))
    result = first.union(first)
    assert result == first