Circuit Plot
Matplotlib based plotting of quantum circuits.
Todo:
- Optimize printing of large circuits.
- Get this to work with single gates.
- Do a better job checking the form of circuits to make sure it is a Mul of
Gates.
- Get multi-target gates plotting.
- Get initial and final states to plot.
- Get measurements to plot. Might need to rethink measurement as a gate
issue.
- Get scale and figsize to be handled in a better way.
- Write some tests/examples!
-
class sympy.physics.quantum.circuitplot.CircuitPlot(c, nqubits, **kwargs)
A class for managing a circuit plot.
-
control_line(gate_idx, min_wire, max_wire)
Draw a vertical control line.
-
control_point(gate_idx, wire_idx)
Draw a control point.
-
not_point(gate_idx, wire_idx)
Draw a NOT gates as the circle with plus in the middle.
-
one_qubit_box(t, gate_idx, wire_idx)
Draw a box for a single qubit gate.
-
swap_point(gate_idx, wire_idx)
Draw a swap point as a cross.
-
two_qubit_box(t, gate_idx, wire_idx)
Draw a box for a two qubit gate. Doesn’t work yet.
-
update(kwargs)
Load the kwargs into the instance dict.
-
sympy.physics.quantum.circuitplot.circuit_plot(c, nqubits, **kwargs)
Draw the circuit diagram for the circuit with nqubits.
Parameters: | c : circuit
The circuit to plot. Should be a product of Gate instances.
nqubits : int
The number of qubits to include in the circuit. Must be at least
as big as the largest \(min_qubits`\) of the gates.
|
-
sympy.physics.quantum.circuitplot.labeller(n, symbol='q')
Autogenerate labels for wires of quantum circuits.
Parameters: | n : int
number of qubits in the circuit
symbol : string
A character string to precede all gate labels. E.g. ‘q_0’, ‘q_1’, etc.
>>> from sympy.physics.quantum.circuitplot import labeller :
>>> labeller(2) :
[‘q_1’, ‘q_0’] :
>>> labeller(3,’j’) :
[‘j_2’, ‘j_1’, ‘j_0’] :
|
-
class sympy.physics.quantum.circuitplot.Mz
Mock-up of a z measurement gate.
This is in circuitplot rather than gate.py because it’s not a real
gate, it just draws one.
-
class sympy.physics.quantum.circuitplot.Mx
Mock-up of an x measurement gate.
This is in circuitplot rather than gate.py because it’s not a real
gate, it just draws one.
-
sympy.physics.quantum.circuitplot.CreateCGate(name, latexname=None)
Use a lexical closure to make a controlled gate.