feat: add abstractify helper function to core.operator module#9694
Open
andrijapau wants to merge 46 commits into
Open
feat: add abstractify helper function to core.operator module#9694andrijapau wants to merge 46 commits into
abstractify helper function to core.operator module#9694andrijapau wants to merge 46 commits into
Conversation
abstractify helper function
andrijapau
commented
Jun 17, 2026
…nnylane into feat/abstractify-operator
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## fix/skip-child-constructor-if-abstract #9694 +/- ##
=======================================================================
Coverage 99.46% 99.46%
=======================================================================
Files 629 630 +1
Lines 69071 69112 +41
=======================================================================
+ Hits 68700 68742 +42
+ Misses 371 370 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
andrijapau
commented
Jun 19, 2026
andrijapau
commented
Jun 19, 2026
| return _is_op(l) or _is_wires(l) | ||
|
|
||
|
|
||
| @abstractify.register(ABCOperatorMeta) |
Contributor
Author
There was a problem hiding this comment.
Using the metaclass for dispatch seems to work. Anything subtle I'm missing?
mudit2812
reviewed
Jun 19, 2026
mudit2812
reviewed
Jun 19, 2026
| if x.__class__.__name__ == "AbstractArray": | ||
| # will always be a numpy dtype | ||
| return x.dtype.name | ||
| return np.dtype(x.dtype).name |
Contributor
There was a problem hiding this comment.
This can be reverted very soon
Co-authored-by: Mudit Pandey <18223836+mudit2812@users.noreply.github.com>
…nnylane into feat/abstractify-operator
astralcai
reviewed
Jun 22, 2026
Co-authored-by: Astral Cai <astral.cai@xanadu.ai>
andrijapau
commented
Jun 23, 2026
andrijapau
commented
Jun 23, 2026
| return AbstractWires(len(val)) | ||
|
|
||
|
|
||
| @abstractify.register(AbstractArray | AbstractWires) |
Contributor
Author
There was a problem hiding this comment.
Should this go in typing.py? Only issue there is we pick up a dependency for typing to core.operator.
This file contains hidden or 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
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:
We wish to have a helper function that can "abstractify" various types of data. Specfically, this is useful for abstractifying operators for integration with graph decomposition.
Description of the Change:
This PR,
abstractifydispatcher functionabstractifyfunctionso,
Benefits: Utility function is created.
Possible Drawbacks: None identified.
[sc-122587]