Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1feac72

Browse files
committed
fix names in to_dot
1 parent3770528 commit1feac72

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

‎_doc/api/plotting.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Dot
66

77
..autofunction::onnx_array_api.plotting.dot_plot.to_dot
88

9+
..autofunction::onnx_array_api.plotting.graphviz_helper.plot_dot
10+
911
Statistics
1012
++++++++++
1113

‎onnx_array_api/plotting/dot_plot.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ def myloss(x, y):
116116
clean_label_reg2=re.compile("\\\\p\\{[0-9P]{1,6}\\}")
117117

118118
defdot_name(text):
119-
returntext.replace("/","_").replace(":","__").replace(".","_")
119+
return (
120+
text.replace("/","_")
121+
.replace(":","__")
122+
.replace(".","_")
123+
.replace("-","_")
124+
)
120125

121126
defdot_label(text):
122127
iftextisNone:

‎onnx_array_api/plotting/graphviz_helper.py‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def _run_subprocess(
7373
shell=False,
7474
env=os.environ,
7575
stdout=subprocess.PIPE,
76-
stderr=subprocess.STDOUT,
76+
stderr=subprocess.PIPE,
7777
)
7878
raise_exception=False
7979
output=""
@@ -91,12 +91,14 @@ def _run_subprocess(
9191
):
9292
raise_exception=True
9393
p.poll()
94+
error=p.stderr.readline().decode(errors="ignore")
9495
p.stdout.close()
95-
ifraise_exception:
96+
iferrorandraise_exception:
9697
raiseRuntimeError(
97-
"An error was found in the output. The build is stopped.\n{output}"
98+
f"An error was found in the output. The build is stopped."
99+
f"\n{output}\n---\n{error}"
98100
)
99-
returnoutput
101+
returnoutput+"\n"+error
100102

101103

102104
def_run_graphviz(filename:str,image:str,engine:str="dot")->str:
@@ -134,8 +136,12 @@ def _run_graphviz(filename: str, image: str, engine: str = "dot") -> str:
134136
exe=engine
135137
ifos.path.exists(image):
136138
os.remove(image)
137-
output=_run_subprocess([exe,f"-T{ext[1:]}",filename,"-o",image])
138-
assertos.path.exists(image),f"Graphviz failed due to{output}"
139+
cmd= [exe,f"-T{ext[1:]}",filename,"-o",image]
140+
output=_run_subprocess(cmd)
141+
assertos.path.exists(image), (
142+
f"Unable to find{image!r}, command line is "
143+
f"{' '.join(cmd)!r}, Graphviz failed due to\n{output}"
144+
)
139145
returnoutput
140146

141147

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp