-
Notifications
You must be signed in to change notification settings - Fork 578
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
improve builtins shape and ndim; add math.get_deep_interface
#4603
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 task
math.get_deep_interface
mudit2812
approved these changes
Sep 19, 2023
# Conflicts: # doc/releases/changelog-dev.md
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4603 +/- ##
=======================================
Coverage 99.63% 99.63%
=======================================
Files 376 376
Lines 33649 33665 +16
=======================================
+ Hits 33525 33541 +16
Misses 124 124
☔ View full report in Codecov by Sentry. |
albi3ro
reviewed
Sep 20, 2023
# Conflicts: # doc/releases/changelog-dev.md
albi3ro
approved these changes
Oct 3, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context:
Sometimes people do things on lists like
[jnp.array(1.1), jnp.array(2.2)]
and autoray thinks the interface isbuiltins
. This happens a lot withHamiltonian.coeffs
. I'm here to help autoray.Description of the Change:
qml.math.get_deep_interface
to extract out the interface from one of those (arbitrarily) deeply nested lists of lists, or tuples of tuples. Note that I assume the struct isn't ragged, because if you're asking for the interface, you're probably about to cast the whole list and that can fail if it needs tobuiltins
implementation forndim
andshape
to check if it's a nested type containing a different interface. Then, cast to that interface and use its implementation forndim
/shape
Benefits:
We can get the
ndim
/shape
of ugly nested things, and the helper function might be generally helpful elsewherePossible Drawbacks:
None!!!
Related GitHub Issues:
Fixes #4601