Skip to content

Draw circled + for target qubits in SVG diagrams - #8563

Open
mhucka wants to merge 8 commits into
quantumlib:mainfrom
mhucka:svg-use-circled-plus
Open

mhucka wants to merge 8 commits into
quantumlib:mainfrom
mhucka:svg-use-circled-plus

Conversation

@mhucka

@mhucka mhucka commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

This changes the rendering of target qubits in cases such as CNOT gates from the original boxed letter X to the more conventional circled + symbol (⊕). The new scheme is used for CNOT, CCX / TOFFOLI, X.controlled(...), PauliInteractionGate(Z, ..., X, False), and tagged or classically-controlled wrappers around those gates.

Other things are unchanged and left boxed: a standalone X, non-unit powers:(CNOT**0.5, CCX**-1, fractional reversed controls), purely classically controlled X, also XX / PauliString, and multi-'X' spans (such as controlled PauliInteractionGate(X, X) or ControlledGate(ParallelGate(X, 2))).

This work was assisted by Google Gemini.

This changes the rendering of target qubits in cases such as CNOT gates
from the original boxed letter `X` to the more conventional circled `+`
symbol (`⊕`). More specifically, the new scheme is used for `CNOT`,
`CCX` / `TOFFOLI`, `X.controlled(...)`, `PauliInteractionGate(Z, ..., X,
False)`, and tagged or classically-controlled wrappers around those gates.

Other things are unchanged and left boxed: a standalone `X`, non-unit
powers:(`CNOT**0.5`, `CCX**-1`, fractional reversed controls), purely
classically controlled `X`, also `XX` / `PauliString`, and multi-`'X'`
spans (such as controlled `PauliInteractionGate(X, X)` or
`ControlledGate(ParallelGate(X, 2))`).

This work was assisted by Google Gemini.
@github-actions github-actions Bot added size: L 250< lines changed <1000 area/contrib labels Dec 1, 2026
@mhucka

mhucka commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Here are some before and after renderings.

image image

@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.58%. Comparing base (ec3cf39) to head (2029af2).

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #8563    +/-   ##
========================================
  Coverage   99.58%   99.58%            
========================================
  Files        1139     1139            
  Lines      105657   105784   +127     
========================================
+ Hits       105222   105349   +127     
  Misses        435      435            

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mhucka
mhucka marked this pull request as ready for review December 1, 2026 05:42
@mhucka
mhucka requested a review from a team as a code owner December 1, 2026 05:42

@arettig arettig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SVGs look much better! A couple comments below, mostly suggestions on simplifying code.

Comment thread cirq-core/cirq/contrib/svg/svg.py Resolved
Comment thread cirq-core/cirq/contrib/svg/svg_test.py Resolved
Comment thread cirq-core/cirq/contrib/svg/svg_test.py Resolved
Comment thread cirq-core/cirq/contrib/svg/svg.py Resolved
Comment thread cirq-core/cirq/contrib/svg/svg.py Resolved
@mhucka
mhucka requested a review from arettig December 2, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/contrib size: L 250< lines changed <1000

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants