Repository navigation
Fix parameterized diagonal gates failing in circuit diagrams (#8404) - #8464
Open
jyothikacodes wants to merge 1 commit into
Open
jyothikacodes wants to merge 1 commit into
jyothikacodes wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Author
|
Hello @NoureldinYosri @senecameeks , I’ve submitted a PR addressing this issue. I would really appreciate it if you could review it. Thank you for your time and consideration. |
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.
Fixes #8404
Description
In DiagonalGate, TwoQubitDiagonalGate, and ThreeQubitDiagonalGate, circuit_diagram_info previously converted
self._diag_angles_radians into a NumPy array prior to rounding. When diagonal gates contain SymPy symbols or
expressions, NumPy creates an object-dtype array and .round() attempts to call rint on Python objects, causing a
TypeError.
This PR preserves the tuple of angles and applies precision rounding only to non-parameterized elements, allowing
parameterized diagonal gates to render circuit diagrams properly.
Tests
Added regression tests verifying that parameterized diagonal gates with both numeric and symbolic angles render
circuit diagrams correctly with precision formatting:
• cirq-core/cirq/ops/diagonal_gate_test.py
• cirq-core/cirq/ops/two_qubit_diagonal_gate_test.py
• cirq-core/cirq/ops/three_qubit_gates_test.py
Testing Confirmation
│ Running pytest-changed-files, format-incremental, pylint-changed-files, and mypy passes all tests and checks locally
│ using Python 3.14 on Linux OS. Ready for review.