Skip to content

Parameter attr_omit_null in root.show and print_tree does not work as expected. #216

@kevint324

Description

@kevint324

Describe the issue
A clear and concise description of what the bug is.

Here says when attr_omit_null is set,
it is Able to omit showing of attributes if it is null, using attr_omit_null.

Nan value is printed despite of the value of attr_omit_null

Environment
Describe your environment.

  • Platform: [Ubuntu]
  • Python version: 3.10.12
  • bigtree version:0.16.2

To Reproduce

from bigtree import dict_to_tree
from bigtree import Node, print_tree

path_dict4 = {
    "root/moduleA": {},
    "root/moduleA/Package": {},
    "root/moduleA/Package/AAA": {
        "url" : "http://google.com"
    },
    "root/moduleB": {},
    "root/moduleB/Package": {
        "url" : "www.bing.com"
    },
}

root = dict_to_tree(path_dict4)
root.show(attr_list=["url"], attr_omit_null=False)
root.show(attr_list=["url"], attr_omit_null=True)
print_tree(root, attr_list=["url"], attr_omit_null=True)

Expected behaviour
A clear and concise description of what you expected to happen.

The actual output always contains url=nan.
Should this be omitted when "attr_omit_null" is set?

root
├── moduleA [url=nan]
│   └── Package [url=nan]
│       └── AAA [url=http://google.com]
└── moduleB [url=nan]
    └── Package [url=www.bing.com]
root
├── moduleA [url=nan]
│   └── Package [url=nan]
│       └── AAA [url=http://google.com]
└── moduleB [url=nan]
    └── Package [url=www.bing.com]
root
├── moduleA [url=nan]
│   └── Package [url=nan]
│       └── AAA [url=http://google.com]
└── moduleB [url=nan]
    └── Package [url=www.bing.com]

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

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