ASEM000 / pytreeclass

Visualize, create, and operate on pytrees in the most intuitive way possible.
https://pytreeclass.rtfd.io/en/latest
Apache License 2.0
42 stars 2 forks source link

add multi index to `AtIndexer` #71

Closed ASEM000 closed 1 year ago

ASEM000 commented 1 year ago

Select multiple keys at the same level.

The following are all equivalent.

import pytreeclass as pytc

class Tree(pytc.TreeClass):
    a: int = 1
    b: int = 2
    c: int = 3

tree = Tree()

print(tree.at["a", "b"].set(100))
# Tree(a=100, b=100, c=3)

keys = ("a", "b")
print(tree.at[keys].set(100))
# Tree(a=100, b=100, c=3)

# equivalent
print(tree.at["a"].set(100).at["b"].set(100))
# Tree(a=100, b=100, c=3)
codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 95.00% and project coverage change: -0.04 :warning:

Comparison is base (d50188d) 97.82% compared to head (c86d035) 97.79%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #71 +/- ## ========================================== - Coverage 97.82% 97.79% -0.04% ========================================== Files 13 13 Lines 2348 2356 +8 ========================================== + Hits 2297 2304 +7 - Misses 51 52 +1 ``` | [Impacted Files](https://app.codecov.io/gh/ASEM000/PyTreeClass/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mahmoud+Asem) | Coverage Δ | | |---|---|---| | [pytreeclass/\_src/tree\_util.py](https://app.codecov.io/gh/ASEM000/PyTreeClass/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mahmoud+Asem#diff-cHl0cmVlY2xhc3MvX3NyYy90cmVlX3V0aWwucHk=) | `95.45% <91.66%> (-0.16%)` | :arrow_down: | | [pytreeclass/\_src/tree\_base.py](https://app.codecov.io/gh/ASEM000/PyTreeClass/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mahmoud+Asem#diff-cHl0cmVlY2xhc3MvX3NyYy90cmVlX2Jhc2UucHk=) | `98.41% <100.00%> (-0.09%)` | :arrow_down: | | [tests/test\_indexing.py](https://app.codecov.io/gh/ASEM000/PyTreeClass/pull/71?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mahmoud+Asem#diff-dGVzdHMvdGVzdF9pbmRleGluZy5weQ==) | `99.57% <100.00%> (+<0.01%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.