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

3item trace #54

Closed ASEM000 closed 1 year ago

ASEM000 commented 1 year ago

This PR changes the following 1) trace definition (names, types, indices, metadata) -> (names, types, indices) 2) changed the name path of Sequene(list,tuple) to be None. 3) changed index sequence of dict to None.

import pytreeclass as pytc

# Seqeunce data structures without names
tree = [1,2,3]
pytc.tree_leaves_with_trace(tree)
#[(((None,), (int,), (0,)), 1),
# (((None,), (int,), (1,)), 2),
# (((None,), (int,), (2,)), 3)]    

# Mapping data structures without indices
tree = {"a":1}
pytc.tree_leaves_with_trace(tree)
# [((("['a']",), (int,), (None,)), 1)]

# datastructures with both indices and names
from collections import namedtuple
tree = namedtuple("a", ["b", "c"])(1, 2)
pytc.tree_leaves_with_trace(tree)
# ((('b',), (int,), (0,)), 1), ((('c',), (int,), (1,)), 2)]
codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01 :warning:

Comparison is base (842d6b5) 99.60% compared to head (5458d48) 99.60%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #54 +/- ## ========================================== - Coverage 99.60% 99.60% -0.01% ========================================== Files 14 14 Lines 2782 2777 -5 ========================================== - Hits 2771 2766 -5 Misses 11 11 ``` | [Impacted Files](https://codecov.io/gh/ASEM000/PyTreeClass/pull/54?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mahmoud+Asem) | Coverage Δ | | |---|---|---| | [tests/test\_tree\_pprint.py](https://codecov.io/gh/ASEM000/PyTreeClass/pull/54?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mahmoud+Asem#diff-dGVzdHMvdGVzdF90cmVlX3BwcmludC5weQ==) | `98.43% <ø> (ø)` | | | [pytreeclass/\_\_init\_\_.py](https://codecov.io/gh/ASEM000/PyTreeClass/pull/54?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mahmoud+Asem#diff-cHl0cmVlY2xhc3MvX19pbml0X18ucHk=) | `100.00% <100.00%> (ø)` | | | [pytreeclass/\_src/tree\_decorator.py](https://codecov.io/gh/ASEM000/PyTreeClass/pull/54?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mahmoud+Asem#diff-cHl0cmVlY2xhc3MvX3NyYy90cmVlX2RlY29yYXRvci5weQ==) | `100.00% <100.00%> (ø)` | | | [pytreeclass/\_src/tree\_indexer.py](https://codecov.io/gh/ASEM000/PyTreeClass/pull/54?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mahmoud+Asem#diff-cHl0cmVlY2xhc3MvX3NyYy90cmVlX2luZGV4ZXIucHk=) | `99.66% <100.00%> (ø)` | | | [pytreeclass/\_src/tree\_pprint.py](https://codecov.io/gh/ASEM000/PyTreeClass/pull/54?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mahmoud+Asem#diff-cHl0cmVlY2xhc3MvX3NyYy90cmVlX3BwcmludC5weQ==) | `100.00% <100.00%> (ø)` | | | [pytreeclass/\_src/tree\_trace.py](https://codecov.io/gh/ASEM000/PyTreeClass/pull/54?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mahmoud+Asem#diff-cHl0cmVlY2xhc3MvX3NyYy90cmVlX3RyYWNlLnB5) | `100.00% <100.00%> (ø)` | | | [tests/test\_treeclass.py](https://codecov.io/gh/ASEM000/PyTreeClass/pull/54?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mahmoud+Asem#diff-dGVzdHMvdGVzdF90cmVlY2xhc3MucHk=) | `99.16% <100.00%> (-0.01%)` | :arrow_down: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mahmoud+Asem). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Mahmoud+Asem)

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