TransWikia.com

qiskit.QuantumCircuit and qiskit.QuantumCircuit.draw()

Quantum Computing Asked by Gonzo on October 5, 2021

The first time I create a two qubits, two bits circuit and draw it the output is:

q0_0 
q0_1 
c0_0 
c0_1 

Each subsequent time I run my script (even after clearing all the variables) I get the following:

q1_0
q1_1 
c1_0 
c1_1 
. 
. 
. 
qn_0 
qn_1 
cn_0 
cn_1 

The number next to the qubit or classical bit increases every time. Is this a bug, is there a way to avoid this?

I am using Qiskit 0.19.6.

12th time executing my script

13th time executing my script

One Answer

It's not a bug, if you don't give concrete names to the registers then Qiskit will number them increasingly. If you want them to have the same name, you can do that like

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister

qr = QuantumRegister(2, 'q')
cr = ClassicalRegister(2, 'c')
circuit = QuantumCircuit(qr, cr)
circuit.draw()

Answered by Cryoris on October 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP