Commit 7182bd82 by nzy

Fix print_array & Work around ChatGPT's error

parent d21b14ac
...@@ -28,7 +28,15 @@ def syn_anpl(anpl: ANPL): ...@@ -28,7 +28,15 @@ def syn_anpl(anpl: ANPL):
if newanpl: if newanpl:
logger.log("system", "parse_gpt", "success") logger.log("system", "parse_gpt", "success")
if not hole.startswith("_hole"): if not hole.startswith("_hole"):
newanpl.clean(hole) if hole in newanpl.funs:
newanpl.clean(hole)
else:
logger.log("system", "parse_gpt", "do not synthesis the specific hole")
continue
else:
if newanpl.entry in anpl.funs:
logger.log("system", "parse_gpt", "synthesis codes with a used name")
continue
anpl.fill_fun(hole, newanpl) anpl.fill_fun(hole, newanpl)
break break
logger.log("system", "parse_gpt", "error") logger.log("system", "parse_gpt", "error")
......
...@@ -14,19 +14,19 @@ colors = ["#000000", "#0000FF", "#FF0000", "#008000", "#FFFF00", ...@@ -14,19 +14,19 @@ colors = ["#000000", "#0000FF", "#FF0000", "#008000", "#FFFF00",
"#808080", "#FFC0CB", "#FFA500", "#008080", "#800000"] "#808080", "#FFC0CB", "#FFA500", "#008080", "#800000"]
def array_to_str(matrix): def array_to_str(matrix):
if matrix.ndim == 2: if np.issubdtype(matrix.dtype, np.integer):
text = Text() text = Text()
for row in list(matrix): if matrix.ndim == 2:
for pixel in row: for row in list(matrix):
for pixel in row:
text.append("⬛", style=colors[pixel])
text.append("\n")
elif matrix.ndim == 1:
for pixel in list(matrix):
text.append("⬛", style=colors[pixel]) text.append("⬛", style=colors[pixel])
text.append("\n") return text
elif matrix.ndim == 1:
text = Text()
for pixel in list(matrix):
text.append("⬛", style=colors[pixel])
else: else:
text = Text(str(matrix)) return Text(str(matrix))
return text
def rich_dumps(obj): def rich_dumps(obj):
def _dump_recursive(obj): def _dump_recursive(obj):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment