Mixed Type Tree Throws Silent Errors
zapplecat opened this issue · comments
If I were to create a tree mixing types:
root = Node("root")
a = Node(1, parent=root)
Node(2, parent=a)
I can create the tree, although anything that might involve generators, print statements, etc fails.
In [11]: root.show()
root
└── 1
└── 2
In [12]: print(root)
Node(/root, )
In [13]: print(root.children)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[13], line 1
----> 1 print(root.children)
File ~/.pyenv/versions/3.10.4/envs/py310next/lib/python3.10/site-packages/bigtree/node/node.py:225, in Node.__repr__(self)
223 node_dict = self.describe(exclude_prefix="_", exclude_attributes=["name"])
224 node_description = ", ".join([f"{k}={v}" for k, v in node_dict])
--> 225 return f"{class_name}({self.path_name}, {node_description})"
File ~/.pyenv/versions/3.10.4/envs/py310next/lib/python3.10/site-packages/bigtree/node/node.py:119, in Node.path_name(self)
117 ancestors = [self] + list(self.ancestors)
118 sep = ancestors[-1].sep
--> 119 return sep + sep.join([node.name for node in reversed(ancestors)])
TypeError: sequence item 1: expected str instance, int found
This is likely due to the join
in Node.path_name
.
Hello, thanks for using bigtree
and spotting this bug! I have implemented a bugfix in v0.10.1, do upgrade bigtree with the command pip install --upgrade bigtree
.