Skip to content

Commit 87e783c

Browse files
Add images to doc example
1 parent 6838d43 commit 87e783c

File tree

7 files changed

+15
-0
lines changed

7 files changed

+15
-0
lines changed

docs/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ _This project uses semantic versioning. Before 1.0.0, this means that every brea
1919
- Added support for alternative way of creating variables using functions
2020
- Add NDarray example
2121
- Render EGraphs with `graphviz` in the notebook
22+
- Add images to doc examples
2223
- Add `%%egglog` magic to the notebook
2324

2425
## 0.4.0 (2023-05-03)

python/egglog/egraph.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,15 @@ def _repr_mimebundle_(self, *args, **kwargs):
603603
def graphviz(self) -> graphviz.Source:
604604
return graphviz.Source(self._egraph.to_graphviz_string())
605605

606+
def _repr_html_(self) -> str:
607+
"""
608+
Add a _repr_html_ to be an SVG to work with sphinx gallery
609+
ala https://github.com/xflr6/graphviz/pull/121
610+
until this PR is merged and released
611+
https://github.com/sphinx-gallery/sphinx-gallery/pull/1138
612+
"""
613+
return self.graphviz.pipe(format="svg").decode()
614+
606615
def display(self):
607616
"""
608617
Displays the e-graph in the notebook.

python/egglog/examples/eqsat_basic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ def __mul__(self, other: Num) -> Num: # type: ignore[empty-body]
4040
)
4141
egraph.run(10)
4242
egraph.check(eq(expr1).to(expr2))
43+
egraph

python/egglog/examples/fib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ def fib(x: i64Like) -> i64: # type: ignore[empty-body]
2525
)
2626
egraph.run(7)
2727
egraph.check(eq(fib(i64(7))).to(i64(21)))
28+
egraph

python/egglog/examples/matrix.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,4 @@ def kron(a: Matrix, b: Matrix) -> Matrix: # type: ignore[empty-body]
181181
egraph.run(10)
182182
# Verify it is not simplified
183183
egraph.check_fail(eq(ex2).to(kron(A, C)))
184+
egraph

python/egglog/examples/resolution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,4 @@ def pred(x: i64Like) -> Bool: # type: ignore[empty-body]
8181
egraph.check(T != F)
8282
egraph.check(eq(p0).to(F))
8383
egraph.check(eq(p2).to(F))
84+
egraph

python/egglog/examples/schedule_demo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@
3030
)
3131
egraph.check(left(i64(10)), right(i64(9)))
3232
egraph.check_fail(left(i64(11)), right(i64(10)))
33+
egraph

0 commit comments

Comments
 (0)