Skip to content

potential bug for data parameter in Node #206

@cli0

Description

@cli0

I am trying to filter nodes based on custom parameters that I uploaded in the data field. Namely I create a class and assign to dataa particular class.

However when I try to go through the nodes via filter, the node.data is not recognized and gives me a Nonetype. The following is my code and errors:

def tree():
    tree = Tree()
    tree.create_node("Harry", "harry")  # root node
    tree.create_node("Jane", "jane", parent="harry", data=Objects({"nae":1,"surname":2},5))
    tree.create_node("Bill", "bill", parent="harry", data=Objects({"nae":1,"surname":2},88))
    tree.create_node("Diane", "diane", parent="jane", data=Objects({"nae":1,"surname":2},2))
    tree.create_node("Mary", "mary", parent="diane", data=Objects({"nae":1,"surname":2},1))
    tree.create_node("Mark", "mark", parent="jane", data= Objects({"nae":1,"surname":2},20))

    x = tree.filter_nodes(lambda y: y.data.b >7)
    for i in x:
        print(i)

AttributeError: 'NoneType' object has no attribute 'b'

Alternatively if I try to filter the tree based on the identifier or tag it all works out fine. Just data is not recognized at all and throws a Nonetype immediately as it is called.

Am I doing something wrong here or is filtering based on data not supported by the library?

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions