Closed tonmoy-b closed 2 months ago
hi @albi3ro and @mudit2812, thanks for the review and suggestions. I have accepted the suggested changes. Do let me know if it would be nice for me to look work on any other contributions, I'd love to get more familiar with the code.
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 99.66%. Comparing base (
1f55c88
) to head (baf9ac7
). Report is 2 commits behind head on master.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Thank you so much for this PR @tonmoy-b 🚀 !! We will continue with the review next week. Have a great weekend!!
Thanks for opening this PR @tonmoy-b ! The implementation looks great. I left some suggestions for the changelog. Do you mind also adding a couple of more tests:
- A test to verify that the pytree structure returned by
flatten
is correct when given anis_leaf
argument.- A test to verify that flattening and then unflattening the same pytree will be equivalent to the original object when
flatten
is given anis_leaf
argument.Other than the above comments, the PR is in great shape and I'm happy to approve once the above comments are resolved 🎉
Hi @mudit2812, @albi3ro @Alex-Preciado ,
I have added the mentioned tests into tests\pytrees\test_pytrees.py, as three functions (test_flatten_is_leaf, test_unflatten_is_leaf, test_unflatten_for_structure_is_leaf), kindly take a look.
Regards
Thank you so much for this contribution @tonmoy-b !! 🚀
Thank you so much for this contribution @tonmoy-b !! 🚀
Thanks Alex, it was my pleasure and I hope to make more contributions to Pennylane going forward.
Context: Add is_leaf argument to pytrees\pytrees.py with test at tests\pytrees\test_pytrees.py fixes #6083
Description of the Change: Added is_leaf argument to the function pytrees\pytrees.py. Should this argument evaluate to True then no fufther flattening will be done. Added test to tests\pytrees\test_pytrees.py, with function test_flatten_is_leaf() having two test cases. Added changelog with file \doc\releases\changelog-0.38.0.md
Benefits: argument added to the function flatten which acts as a control mechanism to designate a node as leaf node even if that node could be further flattened, e.g., the node is a tuple.
Possible Drawbacks:
Related GitHub Issues: Fixes #6083
Related Shortcut Stories: [sc-70903]