Dashboard Core — Circuit Diagram¶
Native circuit-diagram renderer — pure matplotlib, never a Qiskit
QuantumCircuit. Replaces qiskit.circuit.draw(output='mpl') for
exactly the gate set dense_evolution actually supports, so Composer
never depends on Qiskit just to draw a picture.
from dashboard_core.circuit_diagram import draw_native_circuit_diagram
fig = draw_native_circuit_diagram([("h", 0), ("cx", 0, 1)], n_qubits=2)
fig.savefig("bell_pair.png") # a matplotlib.figure.Figure, save/show it like any other
circuit_diagram ¶
Native circuit-diagram renderer -- pure matplotlib, never a Qiskit QuantumCircuit. Replaces qiskit's circuit.draw(output='mpl') for exactly the reason documented in dashboard_core/engine.py's module docstring: qiskit.circuit.QuantumCircuit.init itself segfaults (SIGSEGV) on macOS CI runners, on the simplest possible call (QuantumCircuit(3) alone, no QASM, no methods called on it) -- see tests/integration/test_interop.py:: TestQiskitInterop for the full reproduction story. There is no way to keep using Qiskit's own drawer without constructing that object, so this module draws directly from the same (name, *qubits[, param]) gate-tuple format every other dense_evolution entry point already uses.
Gate vocabulary comes from dashboard_core._gate_tables (_ONE_QUBIT_STATIC / _ONE_QUBIT_PARAM / _TWO_QUBIT_STATIC / _TWO_QUBIT_PARAM / _THREE_QUBIT_STATIC), shared with qasm_library.py -- the same gate set QASMParser can ever hand back, so nothing here can see a name it doesn't recognize. Was a second, independently hand-copied set of these 5 constants until this shared import (prog.txt, dashboard_core audit point 2): this copy was missing the 'u1'/'phase' aliases the other one had, so a circuit using either of those two real gate names crashed this function with "unsupported gate for native circuit diagram" -- a real bug the duplication caused, not just a divergence risk.
draw_native_circuit_diagram ¶
Draws a circuit diagram figure directly from dense_evolution gate tuples -- no Qiskit QuantumCircuit ever constructed. Qubit 0 is drawn at the top, increasing downward, matching Qiskit's own drawer convention so this is a drop-in replacement for dashboard_core.visuals.draw_circuit_figure's panel.
Returns:
| Type | Description |
|---|---|
Figure
|
|
Examples:
>>> from dashboard_core.circuit_diagram import draw_native_circuit_diagram
>>> fig = draw_native_circuit_diagram([('h', 0), ('cx', 0, 1)], n_qubits=2)
>>> type(fig).__name__
'Figure'
>>> fig.savefig('bell_pair.png')
Source code in tools/dashboard/core/circuit_diagram.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
See also: dashboard_core.visuals, which
aggregates this with state_visuals.