Skip to content

Commit

Permalink
Add a visualize flag to egraph.saturate for further configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
orenht committed Jan 29, 2025
1 parent 3829d69 commit e14e29c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions python/egglog/egraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@ def saturate(
*,
expr: Expr | None = None,
max: int = 1000,
visualize: bool = True,
**kwargs: Unpack[GraphvizKwargs],
) -> None:
"""
Expand All @@ -1387,12 +1388,15 @@ def to_json() -> str:
print(self.extract(expr), "\n")
return self._serialize(**kwargs).to_json()

egraphs = [to_json()]
if visualize:
egraphs = [to_json()]
i = 0
while self.run(schedule or 1).updated and i < max:
i += 1
egraphs.append(to_json())
VisualizerWidget(egraphs=egraphs).display_or_open()
if visualize:
egraphs.append(to_json())
if visualize:
VisualizerWidget(egraphs=egraphs).display_or_open()

@classmethod
def current(cls) -> EGraph:
Expand Down

0 comments on commit e14e29c

Please sign in to comment.