-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat(treespec): add methods PyTreeSpec.entry
and PyTreeSpec.child
#88
Conversation
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #88 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 4
Lines 425 429 +4
=========================================
+ Hits 425 429 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
0f76939
to
bf37bf0
Compare
bf37bf0
to
bc62dc1
Compare
bc62dc1
to
0cc58e9
Compare
return GET_ITEM_BORROW<py::list>(GET_ITEM_BORROW<py::tuple>(root.node_data, 1), index); | ||
} | ||
|
||
case PyTreeKind::None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why raise error for None and Leaf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unreachable. For None
and leaf, it will raise IndexError
due to there are no children.
For None
and leaf, root.arity = 0
.
if (index < -root.arity || index >= root.arity) [[unlikely]] {
throw py::index_error("PyTreeSpec::Entry() index out of range.");
}
Description
Describe your changes in detail.
Motivation and Context
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.
You can use the syntax
close #15213
if this solves the issue #15213Types of changes
What types of changes does your code introduce? Put an
x
in all the boxes that apply:Checklist
Go over all the following points, and put an
x
in all the boxes that apply.If you are unsure about any of these, don't hesitate to ask. We are here to help!
make format
. (required)make lint
. (required)make test
pass. (required)