-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Handle None vs NotImplemented correctly in decompose protocol #7553
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7553 +/- ##
==========================================
- Coverage 97.50% 97.50% -0.01%
==========================================
Files 1103 1103
Lines 99640 99661 +21
==========================================
+ Hits 97154 97174 +20
- Misses 2486 2487 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I suppose this is fine, but does it change any behavior? I am a bit worried since decompose is very sensitive to some workflows, so I want to be sure we are not messing anyone up or causing backwards incompatibilities. |
It doesn't change behavior of any of the gates in cirq; it just prevents cirq from executing the same decomposition handlers twice unnecessarily. For gates defined outside of cirq, it would only change behavior if the gate had a In such a case, the simplest fix would be to change that gate's |
The last commit also updated the type signatures of the handler functions since DecompositionContext is never None anymore (fixing #7384). It did not change any logic. |
…mlib#7553) Handle `None` return values consistently with other protocols, to mean that any fallback option should be skipped (xref quantumlib#1655). This allows us to remove the redundant implementations and eliminate redundant executions of the same logic during decomposition, as well as prevent potential bugs where an important aspect of the context could be ignored. Fixes quantumlib#7535 Additionally fixes quantumlib#7384 since DecompositionContext is never None anymore after the removal of the redundant implementations.
…mlib#7553) Handle `None` return values consistently with other protocols, to mean that any fallback option should be skipped (xref quantumlib#1655). This allows us to remove the redundant implementations and eliminate redundant executions of the same logic during decomposition, as well as prevent potential bugs where an important aspect of the context could be ignored. Fixes quantumlib#7535 Additionally fixes quantumlib#7384 since DecompositionContext is never None anymore after the removal of the redundant implementations.
Handle
None
return values consistently with other protocols, to mean that any fallback option should be skipped (xref #1655). This allows us to remove the redundant implementations and eliminate redundant executions of the same logic during decomposition, as well as prevent potential bugs where an important aspect of the context could be ignored.Fixes #7535
Additionally fixes #7384 since DecompositionContext is never None anymore after the removal of the redundant implementations.