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

potential bug for data parameter in Node #206

Open
cli0 opened this issue Feb 23, 2023 · 0 comments
Open

potential bug for data parameter in Node #206

cli0 opened this issue Feb 23, 2023 · 0 comments

Comments

@cli0
Copy link

cli0 commented Feb 23, 2023

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.

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