Display : a console displayer plugin

Quantum circuits have a graphical representation often more explicit than instances of the class Circuit. This module provides tools to display a quantum circuit in a terminal.

Warning

No tools of this module will work in a Jupyter notebook. If you are using Jupyter, please use %qatdisplay magic

A function display() and a plugin Display are defined in this module. The function is used to display a single circuit in the console and the plugin is used to display all circuits composing a Batch.

For instance, the following code will display a Bell pair circuit in a console:

from qat.lang.AQASM import Program, H, CNOT
from qat.core.console import display

# Define Bell pair
prog = Program()
qubits = prog.qalloc(2)
prog.apply(H, qubits[0])
prog.apply(CNOT, qubits)
circ = prog.to_circ()

# Display circuit
display(circ)

The output of this code is:

Circuit (Press Q to quit)

 ┌─┐
─┤H├─●──
 └─┘ │
     │
    ┌┴┐
────┤X├─
    └─┘

If the circuit is too big to be displayed entirely in the terminal, please use arrows on your keyboard to display another part of your circuit. To leave the display mode, press “Q”.

class qat.core.console.Display(batchmode=False)

This plugin will display all circuits of a Batch. Circuits will be printed one by one.

Parameters

batchmode (bool, optional) – if set to True, each circuit will be displayed in the console without waiting for a user input Default: False

compile(batch, specs)

“Compiles” the batch. All circuits of this batch are displayed. To display the next circuit, press “Q” To stop display, press “Ctrl + C”.

Parameters
  • batch (Batch) – all circuits of this batch are displayed

  • specs (HardwareSpecs) – hardware specifications

Returns

Batch

do_post_processing()

Checks if this plugin have to post process results. The result of this function is always “False”.

Returns

bool

post_process(results)

Post processes results

Parameters

results (BatchResult) – post processed result

Returns

BatchResult