Skip to content

use str instead of repr for tags in circuit diagram #6411

@richrines1

Description

@richrines1

Is your feature request related to a use case or problem? Please describe.

currently tags are displayed in circuit diagrams via their repr (implicitly via str(list(tags))). This can lead to some unruly or hard-to-read circuit diagrams, e.g.:

1: ───X^0.5───Rz(0.928π)[cirq.VirtualTag()]───X^0.5───Rz(π)[cirq.VirtualTag()]───────@──────────────────────────────────
                                                                                     │
2: ───X^0.5───Rz(0.072π)[cirq.VirtualTag()]───X^0.5───Rz(-0.5π)[cirq.VirtualTag()]───X───Rz(-1.5π)[cirq.VirtualTag()]───

this could be cleaned up by overriding tag.__repr__, but usually not without breaking the expectation that eval(repr(tagged_op)) == tagged_op

Describe the solution you'd like

it seems like it'd be much more natural (and easier to customize) if the circuit diagram drawer to instead use the tags' strings, e.g.:

1: ───X^0.5───Rz(0.928π)[<virtual>]───X^0.5───Rz(π)[<virtual>]───────@──────────────────────────
                                                                     │
2: ───X^0.5───Rz(0.072π)[<virtual>]───X^0.5───Rz(-0.5π)[<virtual>]───X───Rz(-1.5π)[<virtual>]───

What is the urgency from your perspective for this issue? Is it blocking important work?

P3 - I'm not really blocked by it, it is an idea I'd like to discuss / suggestion based on principle

(happy to work on this if it seems reasonable)

Metadata

Metadata

Assignees

Labels

good first issueThis issue can be resolved by someone who is not familiar with the codebase. A good starting issue.kind/feature-requestDescribes new functionalityno QC knowledge neededWant to contribute to Cirq, but don't know quantum computing? This issue is for you.triage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions