Skip to content

Fix parameterized diagonal gates failing in circuit diagrams (#8404) - #8464

Open
jyothikacodes wants to merge 1 commit into
quantumlib:mainfrom
jyothikacodes:fix-8404-parameterized-diagonal-diagram
Open

jyothikacodes wants to merge 1 commit into
quantumlib:mainfrom
jyothikacodes:fix-8404-parameterized-diagonal-diagram

Conversation

@jyothikacodes

Copy link
Copy Markdown

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.

@jyothikacodes
jyothikacodes requested a review from a team as a code owner October 17, 2026 12:44
@github-actions github-actions Bot added the size: M 50< lines changed <250 label Oct 17, 2026
@google-cla

google-cla Bot commented Oct 17, 2026

Copy link
Copy Markdown

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.

@jyothikacodes

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: M 50< lines changed <250

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Parameterized diagonal gates fail when printing circuit diagrams

1 participant