Skip to content

Commit 33444cf

Browse files
committed
Fixed Tree svg drawing after the addition of __eq__
1 parent e413d09 commit 33444cf

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

CHANGELOG.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
v1.11.1 (2025-04-01)
5+
--------------------
6+
7+
- Fixed Tree SVG rendering (after introducing Tree.__eq__).
8+
49
v1.11 (2025-03-29)
510
------------------
611

src/liblet/display.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,15 @@ class Tree:
220220
children: an :term:`iterable` of trees to become the current tree children.
221221
"""
222222

223+
__INSTANCE_COUNT = 0
224+
223225
def __init__(self, root, children=None):
224226
self.root = root
225227
self.children = list(children) if children else []
226228
if isinstance(root, Mapping):
227229
self.attr = AttrDict(root)
230+
Tree.__INSTANCE_COUNT += 1
231+
self.__instance_count = Tree.__INSTANCE_COUNT
228232

229233
def __iter__(self):
230234
return iter([self.root, *self.children])
@@ -331,14 +335,14 @@ def _gv_graph_(self):
331335
)
332336

333337
def walk(T):
334-
curr = (T.root, T)
338+
curr = (T.root, T.__instance_count)
335339
G.node(curr)
336340
for child in T.children:
337-
G.edge(curr, (child.root, child))
341+
G.edge(curr, (child.root, child.__instance_count))
338342
if len(T.children) > 1:
339343
with G.subgraph(edge_attr={'style': 'invis'}, graph_attr={'rank': 'same'}) as S:
340344
for f, t in pairwise(T.children):
341-
G.edge((f.root, f), (t.root, t), S)
345+
G.edge((f.root, f.__instance_count), (t.root, t.__instance_count), S)
342346
for child in T.children:
343347
walk(child)
344348

0 commit comments

Comments
 (0)