Skip to content

Commit e881c4a

Browse files
agurfinkelNikolajBjorner
authored andcommitted
Support repr_html for jupyter
1 parent 228d68f commit e881c4a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/api/python/z3/z3.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ class Z3PPObject:
296296
def use_pp(self):
297297
return True
298298

299+
def _repr_html_(self):
300+
in_html = in_html_mode()
301+
set_html_mode(True)
302+
res = repr(self)
303+
set_html_mode(in_html)
304+
return res
305+
306+
299307
class AstRef(Z3PPObject):
300308
"""AST are Direct Acyclic Graphs (DAGs) used to represent sorts, declarations and expressions."""
301309
def __init__(self, ast, ctx=None):
@@ -6418,6 +6426,13 @@ def __repr__(self):
64186426
else:
64196427
return "unknown"
64206428

6429+
def _repr_html_(self):
6430+
in_html = in_html_mode()
6431+
set_html_mode(True)
6432+
res = repr(self)
6433+
set_html_mode(in_html)
6434+
return res
6435+
64216436
sat = CheckSatResult(Z3_L_TRUE)
64226437
unsat = CheckSatResult(Z3_L_FALSE)
64236438
unknown = CheckSatResult(Z3_L_UNDEF)

0 commit comments

Comments
 (0)