Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifying a node's identifier with the . and = operator breaks the tree #200

Open
carlos-montano-hub opened this issue May 19, 2022 · 0 comments

Comments

@carlos-montano-hub
Copy link

making use of the . and = in order to modify a node's identifier causes the node to disappear

Ex:

tree["old_identifier"].identifier = "new_identifier "

the code I used to reproduce the issue:

from treelib import Node, Tree

def create_tree():
    tree = Tree()
    tree.create_node("root" , "root")
    for i in range(2):
        id = str(i*100)
        tree.create_node(id, id , parent = "root")
        for j in range(1, 3):
            id = str(i) + str(j*10)
            tree.create_node(id, id , parent = str(i *100))
            for k in range(1, 3):
                id = str(i) + str(j) + str(k)
                tree.create_node(id, id , parent = str(i) + str(j*10))
    tree.show()
    return tree

def break_tree(tree):
    tree["020"].identifier = "030"
    tree.show()

tree = create_tree()
break_tree(tree)

this outputs:

root
├── 0
│   ├── 010
│   │   ├── 011
│   │   └── 012
│   └── 020
│       ├── 021
│       └── 022
└── 100
    ├── 110
    │   ├── 111
    │   └── 112
    └── 120
        ├── 121
        └── 122

Tree is empty
root
├── 0
│   ├── 010
│   │   ├── 011
│   │   └── 012

if you don’t mind I can work on this and please let me know if you have any feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant