9

This is a duplicate of a question that was asked on the Cirq issues page. I'm duplicating this question to increase it's visibility.

Victory Omole
  • 2,332
  • 1
  • 10
  • 24

1 Answers1

1

The standard way to print circuits in Cirq is by calling print(circuit): which prints the text diagram representation of the circuit. A "prettier" representation can be displayed with SVGCircuit. In a Jupyter notebook,

import cirq
from cirq.contrib.svg import SVGCircuit

a, b = cirq.LineQubit.range(2) SVGCircuit(cirq.Circuit(cirq.X(a), cirq.CNOT(a,b)))

outputs: enter image description here

SVGCircuit is a work-in-progress. Please add comments explaining what problems you run into on the Circuit.repr_svg with nice diagrams for ipython issue.

Victory Omole
  • 2,332
  • 1
  • 10
  • 24