qiskit
qiskit copied to clipboard
Some QuantumCircuit methods have `label` parameter, some not.
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.
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!
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.
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
Newcomer here. I am interested in taking this once we reach a decision! I can take the label issue at the same time.
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!
I am new to contributing and I would love to work on this if its ok.
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 😄
Considering this seems abandoned would I be able to try fixing this instead?
Sure @aprew go ahead! Let us know if you have any questions, and you can take a look at the following resources as well:
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! :)
Assignee move to @aprew. Thanks and let us know if you have time to work on this
Is this still being worked on? If not I am interested in trying to fix the issue.
Hi, sorry yes it is. I'll spare you the excuses but I will start working on it again soon.
@aprew is this still being worked on ? if not i would like to give it a shot
Is this issue still being worked on? I would like to give it a shot also
hi @muhundet ! you are in! (sorry for the delay)
I'd also like to throw my hat in the ring, if there's still work to be done here.
Happy to take this ( assuming it isn't being worked on by @muhundet nor @CB2999 )