Skip to content

Commit e14e29c

Browse files
committed
Add a visualize flag to egraph.saturate for further configuration
1 parent 3829d69 commit e14e29c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

python/egglog/egraph.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,7 @@ def saturate(
13721372
*,
13731373
expr: Expr | None = None,
13741374
max: int = 1000,
1375+
visualize: bool = True,
13751376
**kwargs: Unpack[GraphvizKwargs],
13761377
) -> None:
13771378
"""
@@ -1387,12 +1388,15 @@ def to_json() -> str:
13871388
print(self.extract(expr), "\n")
13881389
return self._serialize(**kwargs).to_json()
13891390

1390-
egraphs = [to_json()]
1391+
if visualize:
1392+
egraphs = [to_json()]
13911393
i = 0
13921394
while self.run(schedule or 1).updated and i < max:
13931395
i += 1
1394-
egraphs.append(to_json())
1395-
VisualizerWidget(egraphs=egraphs).display_or_open()
1396+
if visualize:
1397+
egraphs.append(to_json())
1398+
if visualize:
1399+
VisualizerWidget(egraphs=egraphs).display_or_open()
13961400

13971401
@classmethod
13981402
def current(cls) -> EGraph:

0 commit comments

Comments
 (0)