Skip to content

Follow up work on Circuit._repr_svg_ #4499

@freyam

Description

@freyam

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

@mpharrigan did an amazing job working on adding the SVG representation for a Cirq.Circuit. He left some TODOs in his Issue (#2313). In this issue, I plan to address them and open them for further discussion.

Describe the solution you'd like
Listing the tasks from #2313,

Bugs

  • [BUG] Take care of the SVG circuits when the cirq.Moment() is empty (Currently, it fails).
  • [BUG] Refactor the rendering code such that circuits do not require integer coordinates for spacing routines.
  • [BUG] Implement a dynamic horizontal spacing framework for the rows in the SVGs of the circuits.

Design (A detailed RFC will be opened for this)

  • [DESIGN] Come up with a way to visualize custom gates (MatrixGate).
  • [DESIGN] Revamp the SVG output and make it more informative, illustrative, and colorful.

Testing

  • [TESTING] Add thorough tests.

Ideally, once this issue is fixed, we can think of moving the SVG representation under cirq.Circuit itself.
This would require moving the code out from contrib.

Integration

  • [IMPLEMENTATION] Generalize the code used in cirq-core/cirq/circuits/_block_diagram_drawer.py and cirq-core/cirq/contrib/svg/svg.py to draw the blocks.
  • [INTEGRATION] Dissolve the SVGCircuit class and integrate SVGCircuit._repr_svg_ in cirq.Circuit (or even cirq.AbstractCircuit).

Additional context (e.g. screenshots)

Current Implementation

Current Implementation

What is the urgency from your perspective for this issue? Is it blocking important work?
P2 - we should do it in the next couple of quarters

cc @tanujkhattar

Metadata

Metadata

Labels

area/circuitskind/feature-requestDescribes new functionalitytriage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked on

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions