Skip to content

Commit 4a21ea3

Browse files
author
Judd
committed
save graphs
1 parent eed20b7 commit 4a21ea3

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/alphageometry.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
DEFINITIONS = None # contains definitions of construction actions
3333
RULES = None # contains rules of deductions
34-
PLOT = True
3534
LM = None
3635

3736
def natural_language_statement(logical_statement: pr.Dependency) -> str:
@@ -177,13 +176,12 @@ def run_ddar(g: gh.Graph, p: pr.Problem, out_file: str) -> bool:
177176

178177
write_solution(g, p, out_file)
179178

180-
global PLOT
181-
if PLOT:
182-
gh.nm.draw(
183-
g.type2nodes[gh.Point],
184-
g.type2nodes[gh.Line],
185-
g.type2nodes[gh.Circle],
186-
g.type2nodes[gh.Segment])
179+
gh.nm.draw(
180+
g.type2nodes[gh.Point],
181+
g.type2nodes[gh.Line],
182+
g.type2nodes[gh.Circle],
183+
g.type2nodes[gh.Segment],
184+
save_to=(out_file + '.png' if out_file != '' else None))
187185
return True
188186

189187

@@ -687,7 +685,6 @@ def main(FLAGS):
687685
if FLAGS.problem_name != '':
688686
main(FLAGS)
689687
else:
690-
PLOT = False
691688
out_file = FLAGS.out_file
692689
for name in pr.Problem.from_txt_file(FLAGS.problems_file, to_dict=True).keys():
693690
if name.startswith('#'): continue

src/numericals.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,8 +1240,10 @@ def draw(
12401240
ymax = max([p.num.y for p in points])
12411241
plt.margins((xmax - xmin) * 0.1, (ymax - ymin) * 0.1)
12421242

1243-
plt.show(block=block)
1244-
1243+
if save_to is None:
1244+
plt.show(block=block)
1245+
else:
1246+
plt.savefig(save_to)
12451247

12461248
def close_enough(a: float, b: float, tol: float = 1e-12) -> bool:
12471249
return abs(a - b) < tol

0 commit comments

Comments
 (0)