Skip to content

Commit

Permalink
add seqentialize test
Browse files Browse the repository at this point in the history
  • Loading branch information
j042 committed Jan 10, 2024
1 parent 7d2aa11 commit 29dd567
Showing 1 changed file with 69 additions and 5 deletions.
74 changes: 69 additions & 5 deletions tests/test_utils/test_connec.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def one_polygon():
[0, 1],
[1, 2],
[2, 3],
[3, 4],
[4, 5],
[5, 0],
],
Expand All @@ -35,6 +36,7 @@ def two_polygons():
[0, 1],
[1, 2],
[2, 3],
[3, 4],
[4, 5],
[5, 0],
# second, descending.
Expand All @@ -61,6 +63,7 @@ def one_line():
[0, 1],
[1, 2],
[2, 3],
[3, 4],
[4, 5],
],
dtype=int,
Expand All @@ -81,6 +84,7 @@ def two_lines():
[0, 1],
[1, 2],
[2, 3],
[3, 4],
[4, 5],
# second, descending.
[7, 6],
Expand All @@ -96,8 +100,68 @@ def two_lines():
return tl


def test_edges_to_polygons():
"""
test
"""
pass
def test_sequentialize_directed_edges():
# polygon
# as default, it starts at minimum
seq, is_p = gus.utils.connec.sequentialize_edges(
one_polygon(), directed=True
)
assert is_p[0]
assert seq[0] == [0, 1, 2, 3, 4, 5]

seq, is_p = gus.utils.connec.sequentialize_edges(
two_polygons(), directed=True
)
for ip in is_p:
assert ip
assert seq[0] == [0, 1, 2, 3, 4, 5]
assert seq[1] == [6, 10, 9, 8, 7]

seq, is_p = gus.utils.connec.sequentialize_edges(one_line(), directed=True)
assert not is_p[0]
assert seq[0] == [0, 1, 2, 3, 4, 5]

# this one include descending indices.
# it should be able to eliminate 6, as a starting point.
# directed query keeps the direction
seq, is_p = gus.utils.connec.sequentialize_edges(
two_lines(), directed=True
)
for ip in is_p:
assert not ip
assert seq[0] == [0, 1, 2, 3, 4, 5]
assert seq[1] == [10, 9, 8, 7, 6]


def test_sequentialize_edges():
# polygon
# as default, it starts at minimum
seq, is_p = gus.utils.connec.sequentialize_edges(
one_polygon(), directed=False
)
assert is_p[0]
assert seq[0] == [0, 1, 2, 3, 4, 5]

seq, is_p = gus.utils.connec.sequentialize_edges(
two_polygons(), directed=False
)
for ip in is_p:
assert ip
assert seq[0] == [0, 1, 2, 3, 4, 5]
assert seq[1] == [6, 10, 9, 8, 7]

seq, is_p = gus.utils.connec.sequentialize_edges(
one_line(), directed=False
)
assert not is_p[0]
assert seq[0] == [0, 1, 2, 3, 4, 5]

# this one include descending indices.
# non-directed query doesn't keep the direction.
seq, is_p = gus.utils.connec.sequentialize_edges(
two_lines(), directed=False
)
for ip in is_p:
assert not ip
assert seq[0] == [0, 1, 2, 3, 4, 5]
assert seq[1] == [6, 7, 8, 9, 10]

0 comments on commit 29dd567

Please sign in to comment.