Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.26k stars 2.37k forks source link

Problem in drawing circuit for conditional measurement using multiple classical registers #6804

Closed AbeerVaishnav13 closed 3 years ago

AbeerVaishnav13 commented 3 years ago

Information

The qc.draw() function does not draw the quantum circuit properly if we change the order of classical registers while initializing the QuantumCircuit() instance if there is a measurement in the circuit that is conditioned on the output of some other classical register.

What is the current behavior (and how to reproduce the problem)?

Screenshot 2021-07-26 at 1 48 35 PM

Notice that in the above code, we initialize the quantum circuit as:

qc = QuantumCircuit(q_a, q_b, c_a, c_b)

However, if we exchange the classical registers while initializing, like so:

qc = QuantumCircuit(q_a, q_b, c_b, c_a)

we get this, which is the correct circuit... Screenshot 2021-07-26 at 1 48 55 PM

What is the expected behavior?

The circuit in the first image should have the arrows going to the classical register c_b and the dots going to c_a, but here both of them go to c_a.

enavarro51 commented 3 years ago

I can work on this. It may affect all 3 circuit drawers. Thanks for finding it.

AbeerVaishnav13 commented 3 years ago

I can work on this. It may affect all 3 circuit drawers. Thanks for finding it.

Hi @enavarro51 , thanks for taking this up! I checked the "text" circuit drawer and the output of that looked fine to me. However, I didn't check the "latex" option. But anyway you can try both of them out yourself also once :)