Drawing (plain-text circuit diagrams)¶
A plain-text circuit diagram -- the fast way to sanity-check what a gate-tuple list actually
builds, without running it. Deliberately ASCII-only (-, |, *), not Unicode box-drawing, so
a printed diagram survives any console encoding.
drawing ¶
Plain-text circuit diagrams -- the fast way to sanity-check what a
gate-tuple list actually builds without running it, the same job
Qiskit's circuit.draw() or Cirq's text diagrams do.
Uses plain ASCII ('-', '|', '*') rather than Unicode box-drawing characters deliberately: a diagram meant to be printed to a terminal or written to a log file needs to survive whatever console encoding the caller happens to have (this was tested against, and would otherwise crash on, a default Windows cp1252 console).
draw_circuit ¶
Render a circuit (in the gate-tuple form run_circuit accepts) as a plain-text diagram, one gate per column, one line per qubit.
Parameters¶
circuit : list[tuple]
Gate ops, as passed to DenseSVSimulator.run_circuit. Supports
every gate this package's transpiler recognizes: single-qubit
static and parametric gates, cx/cz/cy/cp/crz, swap, and ccx.
n_qubits : int
Number of qubit rows to draw, must be >= 1 (should cover every
qubit index referenced in circuit).
Returns¶
str
Multi-line diagram, one row per qubit (q0: --H----*--, ...).
Print it, or split on '\n' to inspect individual rows.
Examples¶
import dense_evolution as de print(de.draw_circuit([('h', 0), ('cx', 0, 1)], n_qubits=2)) q0: --H----*-- q1: -------X--