8000 i could have actually been putting the test case name there the whole… · dragoncoder047/schemascii@793a07d · GitHub
[go: up one dir, main page]

Skip to content

Commit 793a07d

Browse files
i could have actually been putting the test case name there the whole time cause only #'s are picked up not letters
1 parent 7b1fc28 commit 793a07d

File tree

1 file changed

+77
-33
lines changed

1 file changed

+77
-33
lines changed

test_data/blob_test.py

Lines changed: 77 additions & 33 deletions

Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
1-
import typing
2-
31
strings = [
42
"""
3+
straight rectangle
54
#########################
65
#########################
76
#########################
87
#########################
98
#########################
109
#########################""",
1110
"""
11+
rectangle with slot in it
1212
#########################
1313
#########################
1414
#############
1515
#########################
1616
#########################
1717
""",
1818
"""
19+
rectangle with notch
20+
###########
21+
###########
22+
##########
23+
###########
24+
###########""",
25+
"""
26+
average triangle (op-amp)
1927
#
2028
###
2129
#####
@@ -25,6 +33,7 @@
2533
#
2634
""",
2735
"""
36+
long triangle
2837
#
2938
######
3039
###########
@@ -34,6 +43,7 @@
3443
#
3544
""",
3645
"""
46+
stubby triangle
3747
#
3848
#
3949
#
@@ -49,6 +59,7 @@
4959
#
5060
""",
5161
"""
62+
half star (concave)
5263
#
5364
#
5465
#
@@ -68,6 +79,7 @@
6879
#
6980
""",
7081
"""
82+
back end of xor gate
7183
#
7284
#
7385
#
@@ -76,6 +88,7 @@
7688
#
7789
#""",
7890
"""
91+
or gate
7992
######
8093
########
8194
#########
@@ -84,6 +97,27 @@
8497
########
8598
######""",
8699
"""
100+
and gate
101+
#####
102+
#######
103+
#######
104+
########
105+
#######
106+
#######
107+
#####
108+
""",
109+
"""
110+
not gate
111+
#
112+
###
113+
##### ##
114+
###########
115+
##### ##
116+
###
117+
#
118+
""",
119+
"""
120+
big O
87121
###########
88122
#############
89123
###############
@@ -95,13 +129,16 @@
95129
#############
96130
###########""",
97131
"""
132+
thin thing 1
98133
###############
99134
###################""",
100135
"""
136+
thin thing 2
101137
###############
102138
###################
103139
###############""",
104140
"""
141+
zigzag rectangle 1
105142
################
106143
################
107144
################
@@ -111,6 +148,7 @@
111148
################
112149
################""",
113150
"""
151+
zigzag rectangle 2
114152
# # # # # # # #
115153
################
116154
################
@@ -119,6 +157,7 @@
119157
################
120158
# # # # # # # #""",
121159
"""
160+
tilted rhombus
122161
#
123162
####
124163
#######
@@ -137,30 +176,39 @@
137176
####
138177
#""",
139178
"""
140-
###########
141-
###########
142-
##########
143-
###########
144-
###########"""]
145-
146-
"""
147-
idea for new algorithm
148-
* find all of the edge points
149-
* sort them by clockwise order around the perimeter
150-
* this is done not by sorting by angle around the centroid
151-
(that would only work for convex shapes) but by forming a list
152-
of edges between adjacent points and then walking the graph
153-
using a direction vector that is rotated only clockwise
154-
and starting from the rightmost point and starting down
155-
* handle the shapes that have holes in them by treating
156-
each edge as a separate shape, then merging the svgs
157-
* find all of the points that are concave
158-
* find all of the straight line points
159-
* assign each straight line point a distance from the nearest
160-
concave point
161-
* remove the concave points and straight line points that are closer
162-
than a threshold and are not a local maximum of distance
179+
and just for the heck of it, a very big arrow
180+
##
181+
####
182+
######
183+
########
184+
##########
185+
############
186+
##############
187+
################
188+
##################
189+
####################
190+
######################
191+
########################
192+
##########################
193+
############################
194+
##############################
195+
################################
196+
##########
197+
##########
198+
##########
199+
##########
200+
##########
201+
##########
202+
##########
203+
##########
204+
##########
205+
##########
206+
##########
207+
##########
208+
##########
209+
##########
163210
"""
211+
]
164212

165213
VN_DIRECTIONS: list[complex] = [1, 1j, -1, -1j]
166214
DIRECTIONS: list[complex] = [1, 1+1j, 1j, -1+1j, -1, -1-1j, -1j, 1-1j]
@@ -182,21 +230,18 @@ def points_to_edges(
182230
return edges
183231

184232
185-
T = typing.TypeVar("T")
186-
187-
188-
def cir(list: list[T], is_forward: bool) -> list[T]:
233+
def cir[T](list: list[T], is_forward: bool) -> list[T]:
189234
if is_forward:
190235
return list[1:] + [list[0]]
191236
else:
192237
return [list[-1]] + list[:-1]
193238

194239

195-
def triples(v: list[T]) -> list[tuple[T, T, T]]:
240+
def triples[T](v: list[T]) -> list[tuple[T, T, T]]:
196241
return list(zip(cir(v, False), v, cir(v, True)))
197242

198243

199-
def fiveles(v: list[T]) -> list[tuple[T, T, T]]:
244+
def fiveles[T](v: list[T]) -> list[tuple[T, T, T, T, T]]:
200245
x, y, z = cir(v, False), v, cir(v, True)
201246
return list(zip(cir(x, False), x, y, z, cir(z, True)))
202247

@@ -214,8 +259,7 @@ def cull_disallowed_edges(
214259
continue
215260
# if there are multiple directions out of here, find the gaps and
216261
# only keep the ones on the sides of the gaps
217-
gaps = [p1 + d in all_points for d in DIRECTIONS]
218-
tran_5 = fiveles(gaps)
262+
tran_5 = fiveles([p1 + d in all_points for d in DIRECTIONS])
219263
# im not quite sure what this is doing
220264
fixed_edges[p1] = set(p1 + d for (d, (q, a, b, c, w))
221265
in zip(DIRECTIONS, tran_5)

0 commit comments

Comments
 (0)
0