caesar0301 / treelib

An efficient implementation of tree data structure in python 2/3.
http://treelib.readthedocs.io/en/latest/
Other
817 stars 188 forks source link

Updates pytree to also accept Node instance instead of nid in some funct... #34

Closed robbert-harms closed 8 years ago

robbert-harms commented 10 years ago

...ions. This solves a bug in add_node()

I had a bug when using add_node to add a node with a given parent node. The changed functions crashed since a node was given to them instead of an ID. I changed the functions to prevent this from happening again.

caesar0301 commented 10 years ago

Its a good feature that should be added in future version. But your modification needs improvement and thorough review about other functions. Adding instance checking code in every function is obviously not the best solution.

robbert-harms commented 10 years ago

Thank you for your reply.

Yes, you are right it is not the optimal solution. I think it is better to make a private method (prefixed with _) that only accepts an id, but make an public method that accepts both.

On 05/15/2014 03:47 PM, Hsiamin wrote:

Its a good feature that should be added in future version. But your modification needs improvement and thorough review about other functions. Adding instance checking code in every function is obviously not the best solution.

— Reply to this email directly or view it on GitHub https://github.com/caesar0301/pyTree/pull/34#issuecomment-43210965.