@@ -14,6 +14,7 @@ def one_polygon():
14
14
[0 , 1 ],
15
15
[1 , 2 ],
16
16
[2 , 3 ],
17
+ [3 , 4 ],
17
18
[4 , 5 ],
18
19
[5 , 0 ],
19
20
],
@@ -35,6 +36,7 @@ def two_polygons():
35
36
[0 , 1 ],
36
37
[1 , 2 ],
37
38
[2 , 3 ],
39
+ [3 , 4 ],
38
40
[4 , 5 ],
39
41
[5 , 0 ],
40
42
# second, descending.
@@ -61,6 +63,7 @@ def one_line():
61
63
[0 , 1 ],
62
64
[1 , 2 ],
63
65
[2 , 3 ],
66
+ [3 , 4 ],
64
67
[4 , 5 ],
65
68
],
66
69
dtype = int ,
@@ -81,6 +84,7 @@ def two_lines():
81
84
[0 , 1 ],
82
85
[1 , 2 ],
83
86
[2 , 3 ],
87
+ [3 , 4 ],
84
88
[4 , 5 ],
85
89
# second, descending.
86
90
[7 , 6 ],
@@ -96,8 +100,68 @@ def two_lines():
96
100
return tl
97
101
98
102
99
- def test_edges_to_polygons ():
100
- """
101
- test
102
- """
103
- pass
103
+ def test_sequentialize_directed_edges ():
104
+ # polygon
105
+ # as default, it starts at minimum
106
+ seq , is_p = gus .utils .connec .sequentialize_edges (
107
+ one_polygon (), directed = True
108
+ )
109
+ assert is_p [0 ]
110
+ assert seq [0 ] == [0 , 1 , 2 , 3 , 4 , 5 ]
111
+
112
+ seq , is_p = gus .utils .connec .sequentialize_edges (
113
+ two_polygons (), directed = True
114
+ )
115
+ for ip in is_p :
116
+ assert ip
117
+ assert seq [0 ] == [0 , 1 , 2 , 3 , 4 , 5 ]
118
+ assert seq [1 ] == [6 , 10 , 9 , 8 , 7 ]
119
+
120
+ seq , is_p = gus .utils .connec .sequentialize_edges (one_line (), directed = True )
121
+ assert not is_p [0 ]
122
+ assert seq [0 ] == [0 , 1 , 2 , 3 , 4 , 5 ]
123
+
124
+ # this one include descending indices.
125
+ # it should be able to eliminate 6, as a starting point.
126
+ # directed query keeps the direction
127
+ seq , is_p = gus .utils .connec .sequentialize_edges (
128
+ two_lines (), directed = True
129
+ )
130
+ for ip in is_p :
131
+ assert not ip
132
+ assert seq [0 ] == [0 , 1 , 2 , 3 , 4 , 5 ]
133
+ assert seq [1 ] == [10 , 9 , 8 , 7 , 6 ]
134
+
135
+
136
+ def test_sequentialize_edges ():
137
+ # polygon
138
+ # as default, it starts at minimum
139
+ seq , is_p = gus .utils .connec .sequentialize_edges (
140
+ one_polygon (), directed = False
141
+ )
142
+ assert is_p [0 ]
143
+ assert seq [0 ] == [0 , 1 , 2 , 3 , 4 , 5 ]
144
+
145
+ seq , is_p = gus .utils .connec .sequentialize_edges (
146
+ two_polygons (), directed = False
147
+ )
148
+ for ip in is_p :
149
+ assert ip
150
+ assert seq [0 ] == [0 , 1 , 2 , 3 , 4 , 5 ]
151
+ assert seq [1 ] == [6 , 10 , 9 , 8 , 7 ]
152
+
153
+ seq , is_p = gus .utils .connec .sequentialize_edges (
154
+ one_line (), directed = False
155
+ )
156
+ assert not is_p [0 ]
157
+ assert seq [0 ] == [0 , 1 , 2 , 3 , 4 , 5 ]
158
+
159
+ # this one include descending indices.
160
+ # non-directed query doesn't keep the direction.
161
+ seq , is_p = gus .utils .connec .sequentialize_edges (
162
+ two_lines (), directed = False
163
+ )
164
+ for ip in is_p :
165
+ assert not ip
166
+ assert seq [0 ] == [0 , 1 , 2 , 3 , 4 , 5 ]
167
+ assert seq [1 ] == [6 , 7 , 8 , 9 , 10 ]
0 commit comments