def test_segments():
    chain = PolygonalChain((0, 1, 4, 8))
    segments = list(chain.segments())
    assert len(segments) == 3
    assert segments[0] == LineSegment((0, 1))
    assert segments[1] == LineSegment((1, 4))
    assert segments[2] == LineSegment((4, 8))
Пример #2
0
def test_adjacent_vertex_indices_3():
    chain = LineSegment((1, 4))
    triplets = list(chain.adjacent_vertex_indices(3))
    assert len(triplets) == 2
    assert triplets[0] == (1, 4, 1)
    assert triplets[1] == (4, 1, 4)
Пример #3
0
def test_adjacent_vertex_indices_2():
    chain = LineSegment((1, 4))
    pairs = list(chain.adjacent_vertex_indices(2))
    assert len(pairs) == 2
    assert pairs[0] == (1, 4)
    assert pairs[1] == (4, 1)
Пример #4
0
def test_adjacent_vertex_indices_1():
    chain = LineSegment((1, 4))
    singles = list(chain.adjacent_vertex_indices(1))
    assert len(singles) == 2
    assert singles[0] == (1, )
    assert singles[1] == (4, )
Пример #5
0
def test_repr():
    assert (repr(LineSegment(
        (67018, 67019))) == "LineSegment(vertex_indices=(67018, 67019))")
Пример #6
0
def test_eq():
    assert LineSegment((67018, 67019)) == LineSegment((67018, 67019))
    assert LineSegment((67018, 67019)) == LineSegment((67019, 67018))
    assert LineSegment((67019, 67018)) == LineSegment((67018, 67019))
Пример #7
0
def test_init_fail():
    with pytest.raises(Exception):
        LineSegment((1, 2, 3))