Dashboard Core — Graphical Builder¶
Turns the ops list produced by the graphical (drag-and-drop) circuit
builder component into dense_evolution's own (name, *qubits[, param])
gate-tuple format, so a circuit built visually runs through the exact
same execution path as one written in OpenQASM.
from dashboard_core.graphical_builder import ops_to_native_tuples
# A Bell pair, as the drag-and-drop grid would emit it:
ops = [{"gate": "h", "qubits": [0]}, {"gate": "cx", "qubits": [0, 1]}]
tuples = ops_to_native_tuples(n_qubits=2, ops=ops)
print(tuples) # [('h', 0), ('cx', 0, 1)]
# Feed straight into gate_tuples_to_qasm for the QASM the rest of the Composer runs on:
from dashboard_core.qasm_library import gate_tuples_to_qasm
print(gate_tuples_to_qasm(tuples, n_qubits=2))
graphical_builder ¶
Turns the ops list produced by the graphical (drag-and-drop) circuit builder component into dense_evolution's own (name, *qubits[, param]) gate tuples -- the same format dashboard_core.engine already runs on the real dense_evolution DenseSVSimulator (via dashboard_core.qasm_library. gate_tuples_to_qasm for the QASM round-trip). No separate execution path for graphically-built circuits, and no Qiskit QuantumCircuit ever built here: they go through the exact same engine as typed OpenQASM.
ops_to_native_tuples ¶
Build dense_evolution's own (name, *qubits[, param]) gate tuples from the builder's op list -- the same shape dashboard_core.engine's QASMParser-based pipeline and qasm_library.gate_tuples_to_qasm both already accept, and the same validation the old QuantumCircuit-based version did (qubit range, unknown gate name), just performed by hand instead of relying on Qiskit's own checks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_qubits
|
int
|
|
required |
ops
|
list[dict]
|
Each dict has 'gate' (one of the GATE_PALETTE gate ids: h/x/y/z/s/t/ rx/ry/rz/cx/cy/cz/swap) and 'qubits' (list[int]). |
required |
Notes
A graphically-placed rx/ry/rz always gets a fixed pi/2 rotation angle (_DEFAULT_ROTATION_ANGLE, prog.txt dashboard_core audit point 5d) -- the drag-and-drop grid has no angle-entry UI yet, so this places a real, working rotation rather than a fake/placeholder one. A user who drops an Rx expecting to pick its own angle should know this is fixed, not something this function silently decided for them.
Returns:
| Type | Description |
|---|---|
list[tuple]
|
Pass to qasm_library.gate_tuples_to_qasm(tuples, n_qubits) for the QASM text the rest of the Composer already runs on (measure_all equivalent included there by default). |
Examples:
>>> from dashboard_core.graphical_builder import ops_to_native_tuples
>>> ops = [{'gate': 'h', 'qubits': [0]}, {'gate': 'cx', 'qubits': [0, 1]}]
>>> ops_to_native_tuples(2, ops)
[('h', 0), ('cx', 0, 1)]
Source code in tools/dashboard/core/graphical_builder.py
See also: dashboard_core.circuit_builder_component,
the UI component this module's output feeds.