qiskit icon indicating copy to clipboard operation
qiskit copied to clipboard

Some QuantumCircuit methods have `label` parameter, some not.

Open enavarro51 opened this issue 4 years ago • 18 comments

Information

  • Qiskit Terra version: master
  • Python version: 3.8
  • Operating system: Ubuntu 18.04

What is the current behavior?

The following controlled-gate methods in QuantumCircuit do not accept label or ctrl_state as a param.

  • ccx, toffoli, mcx, rccx, rcccx, fredkin, mcu1

Steps to reproduce the problem

from qiskit import QuantumCircuit

qc = QuantumCircuit(3)
qc.cx(0, 1, label='Label', ctrl_state=0)
qc.ccx(0, 1, 2, label='Label', ctrl_state=1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-19-decb3879596f> in <module>
      3 qc = QuantumCircuit(3)
      4 qc.cx(0, 1, label='Label', ctrl_state=0)
----> 5 qc.ccx(0, 1, 2, label='Label', ctrl_state=1)

TypeError: ccx() got an unexpected keyword argument 'label'

What is the expected behavior?

All the above gates should accept label and ctrl_state

Suggested solutions

Add label and ctrl_state to the above methods in QuantumCircuit class and pass them through to gate classes.

enavarro51 avatar Sep 21 '20 17:09 enavarro51

Definitely seems odd, especially since the controlled-gate classes for the ones without labels are subclasses of the same ControlledGate class, with an initializer taking labels as parameters. I'd be happy to work on this!

shifubear avatar Sep 22 '20 03:09 shifubear

I agree this is an inconsistency. However, I think the solution is to remove them from those that have the label, not adding to those that are missing it. If a label is required, I think is reasonable to use the .append notation.

1ucian0 avatar Oct 23 '20 19:10 1ucian0

After some internal discussion it has been decided that the most appropriate fix this issue is to remove the label parameter from the QuantumCircuit methods that have it. I'm leaving this issue for the label part of it.

About ctrl_state, moved to https://github.com/Qiskit/qiskit-terra/issues/6465

1ucian0 avatar May 26 '21 14:05 1ucian0

Newcomer here. I am interested in taking this once we reach a decision! I can take the label issue at the same time.

eptru avatar May 27 '21 14:05 eptru

Thanks @eptru! it looks like #6465 is already being worked on, but I'll assign this one to you 😄 Let us know if you have any questions!

javabster avatar Jun 04 '21 15:06 javabster

I am new to contributing and I would love to work on this if its ok.

fs1132429 avatar Jun 05 '21 07:06 fs1132429

Hi @fs1132429 thanks for your interest but this issue has already been assigned and is being worked on. If you go to the issues tab and search for good first issues there are many that have not yet been assigned to someone which you might like to take on 😄

javabster avatar Jun 07 '21 08:06 javabster

Considering this seems abandoned would I be able to try fixing this instead?

ghost avatar Jul 09 '22 14:07 ghost

Sure @aprew go ahead! Let us know if you have any questions, and you can take a look at the following resources as well:

javabster avatar Jul 11 '22 19:07 javabster

Sure @aprew go ahead! Let us know if you have any questions, and you can take a look at the following resources as well:

* [Contributing Guidelines](https://github.com/Qiskit/qiskit-terra/blob/main/CONTRIBUTING.md)

* [GitHub / CI tips for Qiskit Contributors](https://www.youtube.com/watch?v=-eLeOeF_-5o)

Will do thank you! :)

ghost avatar Jul 12 '22 18:07 ghost

Assignee move to @aprew. Thanks and let us know if you have time to work on this

1ucian0 avatar Nov 01 '22 06:11 1ucian0

Is this still being worked on? If not I am interested in trying to fix the issue.

PriyanshuPansari avatar Jan 16 '23 14:01 PriyanshuPansari

Hi, sorry yes it is. I'll spare you the excuses but I will start working on it again soon.

ghost avatar Jan 16 '23 14:01 ghost

@aprew is this still being worked on ? if not i would like to give it a shot

jade-emperror avatar Feb 21 '23 15:02 jade-emperror

Is this issue still being worked on? I would like to give it a shot also

muhundet avatar Jun 27 '23 09:06 muhundet

hi @muhundet ! you are in! (sorry for the delay)

1ucian0 avatar Aug 31 '23 19:08 1ucian0

I'd also like to throw my hat in the ring, if there's still work to be done here.

CB2999 avatar Oct 18 '23 23:10 CB2999

Happy to take this ( assuming it isn't being worked on by @muhundet nor @CB2999 )

migueltorrescosta avatar May 03 '24 13:05 migueltorrescosta