qat.core.console.display

Circuits can be displayed in a notebook or inside a terminal. To display a circuit in a terminal, you can use the function qat.core.console.display()

qat.core.console.display(circuit, max_depth=0, circuit_name=None, batchmode=False, renaming_dict=None)

Displays a circuit on the terminal using ASCII art. By default, calls to sub-circuits are not inlined when displaying. You can display the content of a sub-circuit by increasing the maximal depth of inlining.

from qat.core.console import display
from qat.lang.AQASM import Program
from qat.lang.AQASM.qftarith import add

# Define circuit
prog = Program()
qbits = prog.qalloc(5)
prog.apply(add(3, 2), qbits)
circ = prog.to_circ()

# Display circuit
display(circ)

# Display implementation of "add"
display(circ, max_depth=1)

# Display full circuit
display(circ, max_depth=None)
Parameters
  • circuit (Circuit) – displayed circuit

  • max_depth (int, optional) – maximal depth of inlining (None is maximal)

  • circuit_name (str, optional) – name of the circuit

  • batchmode (bool, optional) – if this variable is set to True, this function will not wait for user input

  • renaming_dict (optional, dict) – an alias dictionary to display gates with custom names

Warning

Only GATETYPE operators can be visualized in a terminal. An exception is raised if your circuit contains measures, gates controlled classically, logic operators, …

The display() method can be used to display a circuit in a notebook or in an IPython terminal (this function will detect automatically if qat.core.console.display() or plot_in_notebook() must be used).