visualize#
- visualize(qc: QuantumCircuit) QuantumCircuit[source]#
Print the current circuit to
stdoutfor debugging purposes.A no-op pass that prints the circuit as it is when encountered in a
PassManagerpipeline. Useful for inspecting the circuit between other transformation passes.The pass is always the identity — it never modifies the circuit.
Examples
We showcase how a Toffoli gate is decomposed step by step, inserting a visualization pass after each pass to show the progression.
>>> from qrisp import PassManager, visualize, decompose, QuantumCircuit >>> qc = QuantumCircuit(3) >>> qc.ccx(0, 1, 2) >>> pm = PassManager() >>> pm += visualize >>> pm += decompose(1) >>> pm += visualize >>> pm += decompose(1) >>> pm += visualize >>> pm.run(qc) qb_82: ──■── │ qb_83: ──■── ┌─┴─┐ qb_84: ┤ X ├ └───┘ ┌────────────────┐ qb_82: ┤0 ├ │ │ qb_83: ┤1 gray multi cx ├ │ │ qb_84: ┤2 ├ └────────────────┘ ┌─────┐ qb_82: ┤ Tdg ├───────■─────────■────■───────────────────────■── ├─────┤┌───┐ │ ┌───┐┌─┴─┐ │ ┌─────┐┌───┐ ┌───┐ ┌─┴─┐ qb_83: ┤ Tdg ├┤ X ├──┼──┤ T ├┤ X ├──┼──┤ Tdg ├┤ X ├─┤ T ├─┤ X ├ └┬───┬┘└─┬─┘┌─┴─┐├───┤└───┘┌─┴─┐└─────┘└─┬─┘┌┴───┴┐├───┤ qb_84: ─┤ H ├───■──┤ X ├┤ T ├─────┤ X ├─────────■──┤ Tdg ├┤ H ├ └───┘ └───┘└───┘ └───┘ └─────┘└───┘