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

[BUG] When function returns a treevalue #82

Closed
HansBug opened this issue Mar 6, 2023 · 0 comments · Fixed by #83
Closed

[BUG] When function returns a treevalue #82

HansBug opened this issue Mar 6, 2023 · 0 comments · Fixed by #83
Assignees
Labels
bug Something isn't working

Comments

@HansBug
Copy link
Member

HansBug commented Mar 6, 2023

from treevalue import FastTreeValue


def func(x):
    return FastTreeValue({
        'x': x, 'y': x ** 2,
    })


f = FastTreeValue({
    'x': func,
    'y': {
        'z': func,
    }
})
v = FastTreeValue({'x': 2, 'y': {'z': 34}})
r1 = f(v)
print(r1)

The output is

<FastTreeValue 0x7f13ff6491f0>
├── 'x' --> <FastTreeValue 0x7f13ff6491c0>
│           ├── 'x' --> 2
│           └── 'y' --> 4
└── 'y' --> <FastTreeValue 0x7f13ff649220>
    └── 'z' --> <FastTreeValue 0x7f13ff649130>
                ├── 'x' --> 34
                └── 'y' --> 1156

But the correct output should be

<FastTreeValue 0x7f13ff6498b0>
├── 'x' --> <FastTreeValue 0x7f13ff649a00>
│   ├── 'x' --> 2
│   └── 'y' --> 4
└── 'y' --> <FastTreeValue 0x7f13ff6499a0>
    └── 'z' --> <FastTreeValue 0x7f13ff649910>
        ├── 'x' --> 34
        └── 'y' --> 1156
@HansBug HansBug added the bug Something isn't working label Mar 6, 2023
@HansBug HansBug self-assigned this Mar 6, 2023
@HansBug HansBug changed the title [BUG] [BUG] When function returns a treevalue Mar 6, 2023
@HansBug HansBug linked a pull request Mar 6, 2023 that will close this issue
3 tasks
HansBug added a commit that referenced this issue Mar 6, 2023
fix(hansbug): fix bug of #82, add more unittests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant