Skip to content

Commit

Permalink
save graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
Judd committed Jan 8, 2025
1 parent eed20b7 commit 4a21ea3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
15 changes: 6 additions & 9 deletions src/alphageometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

DEFINITIONS = None # contains definitions of construction actions
RULES = None # contains rules of deductions
PLOT = True
LM = None

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

write_solution(g, p, out_file)

global PLOT
if PLOT:
gh.nm.draw(
g.type2nodes[gh.Point],
g.type2nodes[gh.Line],
g.type2nodes[gh.Circle],
g.type2nodes[gh.Segment])
gh.nm.draw(
g.type2nodes[gh.Point],
g.type2nodes[gh.Line],
g.type2nodes[gh.Circle],
g.type2nodes[gh.Segment],
save_to=(out_file + '.png' if out_file != '' else None))
return True


Expand Down Expand Up @@ -687,7 +685,6 @@ def main(FLAGS):
if FLAGS.problem_name != '':
main(FLAGS)
else:
PLOT = False
out_file = FLAGS.out_file
for name in pr.Problem.from_txt_file(FLAGS.problems_file, to_dict=True).keys():
if name.startswith('#'): continue
Expand Down
6 changes: 4 additions & 2 deletions src/numericals.py
Original file line number Diff line number Diff line change
Expand Up @@ -1240,8 +1240,10 @@ def draw(
ymax = max([p.num.y for p in points])
plt.margins((xmax - xmin) * 0.1, (ymax - ymin) * 0.1)

plt.show(block=block)

if save_to is None:
plt.show(block=block)
else:
plt.savefig(save_to)

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

0 comments on commit 4a21ea3

Please sign in to comment.