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

dev(hansbug): fix support of rise and subside for namedtuple #76

Merged
merged 2 commits into from
Feb 24, 2023

Conversation

HansBug
Copy link
Member

@HansBug HansBug commented Feb 24, 2023

from collections import namedtuple

from treevalue import FastTreeValue, subside, rise

nt = namedtuple('nt', ['a', 'b', 'c'])

if __name__ == '__main__':
    a = nt(
        FastTreeValue({'x': 1, 'y': 2, 'z': {'v': 3}}),
        FastTreeValue({'x': 4, 'y': 5, 'z': {'v': 6}}),
        FastTreeValue({'x': 7, 'y': 8, 'z': {'v': 9}}),
    )
    t = subside(a)
    print(t)

    origin = rise(t)
    print(origin)

The output should be

<FastTreeValue 0x7f612b92fc90>
├── 'x' --> nt(a=1, b=4, c=7)
├── 'y' --> nt(a=2, b=5, c=8)
└── 'z' --> <FastTreeValue 0x7f612b92fe50>
    └── 'v' --> nt(a=3, b=6, c=9)

nt(a=<FastTreeValue 0x7f612b92fdd0>
├── 'x' --> 1
├── 'y' --> 2
└── 'z' --> <FastTreeValue 0x7f612b92fd10>
    └── 'v' --> 3
, b=<FastTreeValue 0x7f612b92fa50>
├── 'x' --> 4
├── 'y' --> 5
└── 'z' --> <FastTreeValue 0x7f612b92f9d0>
    └── 'v' --> 6
, c=<FastTreeValue 0x7f612b92f910>
├── 'x' --> 7
├── 'y' --> 8
└── 'z' --> <FastTreeValue 0x7f612b92f890>
    └── 'v' --> 9
)

@HansBug HansBug self-assigned this Feb 24, 2023
@codecov
Copy link

codecov bot commented Feb 24, 2023

Codecov Report

Merging #76 (be32736) into main (d99d476) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main      #76   +/-   ##
=======================================
  Coverage   99.01%   99.01%           
=======================================
  Files          36       36           
  Lines        2537     2544    +7     
=======================================
+ Hits         2512     2519    +7     
  Misses         25       25           
Flag Coverage Δ
unittests 99.01% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
treevalue/tree/tree/structural.pyx 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@HansBug HansBug merged commit ef52316 into main Feb 24, 2023
@HansBug HansBug deleted the fix/namedtuple branch February 24, 2023 07:15
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

Successfully merging this pull request may close these issues.

None yet

2 participants