Skip to content

get_tree_diff unable to handle non-default separators #306

@villega6

Description

@villega6

Describe the issue

Using get_tree_diff with non-default separators leads to an incorrect tree_diff

Environment

  • Platform: MacOS
  • Python version: 3.9.18
  • bigtree version: 0.21.2

To Reproduce

from bigtree import Node, get_tree_diff

tree = Node("root")
other_tree = Node("root")
Node("leaf", parent=other_tree)

print("Default separator:")
get_tree_diff(tree, other_tree).show()

tree = Node("root", sep="╞")
other_tree = Node("root", sep="╞")
Node("leaf", parent=other_tree, sep="╞")

print("Custom separator:")
get_tree_diff(tree, other_tree).show()
>> Default separator:
>> root
>> └── leaf (+)
>> Custom separator:
>> ╞root╞leaf (+)

Expected behaviour

tree_diff with custom separator should look like this:

root
└── leaf (+)

Screenshots

No response

Additional context

I believe this may be related missing parameter in line 408 in helper.py.

Since tree and other_tree need to have the same sep, data_both will have the paths built with that separator. It seems just right to pass it to dataframe_to_tree for it to be able to reconstruct the tree_diff.

        tree_diff = construct.dataframe_to_tree(data_both, node_type=tree.__class__, sep=tree.sep)

Final Check

  • I will watch this issue to stay updated with any comments or requests for additional information. I understand that timely responses will help in resolving the issue more quickly.

  • I have thoroughly searched the documentation, and I have also checked for existing solutions or similar issues before submitting this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions