Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drawing error in circuits with isolated qubits #6732

Closed
2 tasks
TharrmashasthaPV opened this issue Jul 13, 2021 · 5 comments · Fixed by #6942
Closed
2 tasks

Drawing error in circuits with isolated qubits #6732

TharrmashasthaPV opened this issue Jul 13, 2021 · 5 comments · Fixed by #6942
Assignees
Labels
bug Something isn't working optional-registers stable backport potential The bug might be minimal and/or import enough to be port to stable
Milestone

Comments

@TharrmashasthaPV
Copy link
Contributor

Information

  • Qiskit Terra version: 0.18
  • Python version: 3.7

What is the current behavior?

When a QuantumCircuit is initialized as QuantumCircuit([Qubit(), Qubit()]), the draw() method has some errors

Steps to reproduce the problem

from qiskit import *
from qiskit.circuit import Qubit

qc = QuantumCircuit([Qubit(), Qubit(), Qubit()])
qc.draw('text')

returns

    
_0: 
    
_1: 
    
_2: 
    

What is the expected behavior?

It would be better if the qubit labelling is done similar to that in the registerless circuits.

@TharrmashasthaPV TharrmashasthaPV added the bug Something isn't working label Jul 13, 2021
@kdk kdk added this to the 0.19 milestone Jul 13, 2021
@kdk
Copy link
Member

kdk commented Jul 13, 2021

Using _0: for the text drawer was an attempt to mirror the existing convention of {reg_name}_{reg_index} with _{circ_index}, but I agree it's not clear that this is drawing a registerless bit and not just a bug. Suggestions welcome! (Maybe __{circ_index}?)

@TharrmashasthaPV
Copy link
Contributor Author

TharrmashasthaPV commented Jul 16, 2021

@kdk __{circ_index} does look like a good idea. But then I think we might also need a way to distinguish between registerless qubits and registerless clbits (or do we?). For instance,

from qiskit.circuit import *
qc = QuantumCircuit([Qubit(), Qubit()], [Clbit(), Clbit()])
qc.draw()

draws

_0:

_1:

_0:

_1:

which I feel might be confusing.

@enavarro51
Copy link
Contributor

@kdk @TharrmashasthaPV The _ probably doesn't work as well in mpl and latex drawers, since the numbers there are subscripts. I think it would be best to have a solution common to the 3 drawers. I kind of like the raw numbers and maybe a * for classical. Like,

 0:
 1:
 2:
*0:
*1:

Any other non-alphanumeric character could be used. If we can get a consensus on this, I can make the change for all 3 drawers.

@kdk
Copy link
Member

kdk commented Aug 20, 2021

@TharrmashasthaPV @enavarro51 I don't think we need to distinguish between classical and quantum bits in the labels, since they are distinguished by their line type (- vs =) for all three drawers (except empty circuits, but that seems okay to me.)

I do like the suggestion of using raw numbers better than using _N or __N, so let's try that way.

@enavarro51
Copy link
Contributor

Thanks, Kevin. I started looking at this and realized the 3 circuit drawers approach getting the bit names and numbers somewhat differently even though the displayed output is the same. This means for something like this, fixing the problem 3 ways. So I'd like to take a stab at putting the acquisition of bit names and numbers for display into a function in utils.py, that can be called by the 3 drawers, which will fix this and hopefully make maintenance easier in the future.

@kdk kdk added the stable backport potential The bug might be minimal and/or import enough to be port to stable label Aug 23, 2021
@mergify mergify bot closed this as completed in #6942 Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working optional-registers stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
3 participants