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
Cleans up code and refactors tests for single qubit unitary decompositions #4869
Conversation
1. Added TestQubitUnitaryXZXDecomposition 2. Generalized _run_assertions moved to outside 3. Updated tests for TestOneQubitRotDecomposition
Cleans up the single qubit unitaries decompositions for more consistent behaviour, and refactors tests for single qubit unitary decompositions.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4869 +/- ##
==========================================
- Coverage 99.65% 99.64% -0.02%
==========================================
Files 383 383
Lines 34571 34314 -257
==========================================
- Hits 34451 34191 -260
- Misses 120 123 +3 ☔ View full report in Codecov by Sentry. |
Hi @astralcai thanks a lot for this follow up PR. I am not sure it is possible to change the base of this PR because you are external, but that would be nice. Currently it is hard to distinguish your two PRs. If it is not possible, I will wait for the first one to be merged before reviewing. |
All rotation angles will be normalized to the range [-2*pi, 2*pi] for consistency. Additionally, test cases are updated to use analytical results for readability.
@rmoyard Hi, I have made another update to this PR, now normalizing all rotation angles to |
Hi @astralcai ! Once you solve the conflicts I will review this PR. One thing about angles for rotation, our canonical range is |
@rmoyard In this case, I will update the code for the Can I ask why this range is chosen? |
@rmoyard I have updated the PR to remove the angle change. It is ready for review now. |
Thank you I will take a look between today and tomorrow. From what I remember, we wanted to follow the convention by numpy.mod and % where the rest is not negative. We thought it was a better software friendly convention compared to the other one which comes more from physics. |
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.
Thanks for cleaning up the tests and the changes to rot
. It looks great, I have left some comments. Happy to approve after that 💯
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.
I don't have anything to add to @rmoyard's feedback. Thanks @astralcai, this looks great! 🚀
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.
Thanks @astralcai, feel free to merge the PR 💯
Hi, thank you. I don't think I have permission to merge this PR. |
Context:
As I am implementing the XZX single qubit decomposition (#4862), I noticed some issues with the the code and the tests for single qubit unitary decompositions.
Description of the Change:
Cleans up
transforms/decompositions/single_qubit_unitary.py
.rot
decomposition.Refactors
tests/transforms/test_decompositions.py
.return_global_phase=False
as well as whenreturn_global_phase=True
Benefits:
Cleaner code.
Related GitHub Issues:
#4868
#4862