question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Follow up work on `Circuit._repr_svg_`

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tanujkhattarcommented, Nov 8, 2021

@freyam Left a comment on #4630 regarding options for visualizing the MatrixGate – let’s continue the discussion there. Thanks for working on this!

1reaction
vanhalen42commented, Sep 17, 2021

Hi, I’m interested and would like to work on this as well!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: 'Digraph' object has no attribute '_repr_svg_'. How do ...
I was following a course on Pytorch and I'm having this error, when in the video everything is perfect, even though the code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found