@@ -293,12 +293,24 @@ def _to_tree(ast_node):
293293
294294 return _to_tree (node )
295295
296+ def to_lol (self ):
297+ def walk (T ):
298+ return (T .root , * tuple (walk (child ) for child in T .children ))
299+
300+ return walk (self )
301+
296302 def __repr__ (self ):
297303 def walk (T ):
298304 return '({}: {})' .format (T .root , ', ' .join (map (walk , T .children ))) if T .children else f'({ T .root } )'
299305
300306 return walk (self )
301307
308+ def __eq__ (self , other ):
309+ return isinstance (other , Tree ) and self .to_lol () == other .to_lol ()
310+
311+ def __hash__ (self ):
312+ return hash (self .to_lol ())
313+
302314 def _gv_graph_ (self ):
303315 G = GVWrapper (
304316 dict ( # noqa: C408
@@ -712,7 +724,8 @@ def _fmt(r, c):
712724 letstr (self .data [r ], self .fmt ['elem_sep' ], sort = self .fmt ['letstr_sort' ], remove_outer = True ),
713725 )
714726 for r in rows
715- ), True
727+ ),
728+ True ,
716729 )
717730
718731
@@ -735,7 +748,8 @@ def _repr_html_(self):
735748 )
736749 + '</pre></td>'
737750 for l in range (N , L - 1 , - 1 ) # noqa: E741
738- ), True
751+ ),
752+ True ,
739753 )
740754
741755
@@ -777,8 +791,13 @@ def embed_css(custom_css=CUSTOM_CSS):
777791 return HTML (f'<style>{ custom_css } </style>' )
778792
779793
780- def liblet_table (content , as_str = False ):
781- return f'<table class="liblet" data-quarto-disable-processing="true">{ content } </table>' if as_str else HTML (f'<table class=liblet>{ content } </table>' )
794+ def liblet_table (content , as_str = False ):
795+ return (
796+ f'<table class="liblet" data-quarto-disable-processing="true">{ content } </table>'
797+ if as_str
798+ else HTML (f'<table class=liblet>{ content } </table>' )
799+ )
800+
782801
783802def resized_svg_repr (obj , width = 800 , height = 600 ):
784803 if hasattr (obj , '_repr_image_svg_xml' ):
0 commit comments