Skip to content

Commit 59beb6a

Browse files
committed
Add a visualize flag to egraph.saturate for further configuration
1 parent e81e641 commit 59beb6a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

python/egglog/egraph.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,7 @@ def saturate(
13841384
*,
13851385
expr: Expr | None = None,
13861386
max: int = 1000,
1387+
visualize: bool = True,
13871388
**kwargs: Unpack[GraphvizKwargs],
13881389
) -> None:
13891390
"""
@@ -1399,18 +1400,22 @@ def to_json() -> str:
13991400
print(self.extract(expr), "\n")
14001401
return self._serialize(**kwargs).to_json()
14011402

1402-
egraphs = [to_json()]
1403+
if visualize:
1404+
egraphs = [to_json()]
14031405
i = 0
14041406
# Always visualize, even if we encounter an error
14051407
try:
14061408
while (self.run(schedule or 1).updated) and i < max:
14071409
i += 1
1408-
egraphs.append(to_json())
1410+
if visualize:
1411+
egraphs.append(to_json())
14091412
except:
1410-
egraphs.append(to_json())
1413+
if visualize:
1414+
egraphs.append(to_json())
14111415
raise
14121416
finally:
1413-
VisualizerWidget(egraphs=egraphs).display_or_open()
1417+
if visualize:
1418+
VisualizerWidget(egraphs=egraphs).display_or_open()
14141419

14151420
@classmethod
14161421
def current(cls) -> EGraph:

0 commit comments

Comments
 (0)