MCMT generalized gate accepts a label kwarg that seems ignored
See original GitHub issueInformation
- Qiskit Terra version: main @ c3792f9d
- Python version: 3.6
- Operating system: osx 10.15.7
What is the current behavior?
mcmt from library allows a label kwarg, but it doens’t go anywhere?
Steps to reproduce the problem
The generalized gate MCMT
accepts a label
kwarg, which it will set to be self.label
, but as a subclass of QuantumCircuit
, it does not look like this attribute will be read anywhere (or at least, I couldn’t find anywhere where it was used.)
>>> from qiskit.circuit.library import *
>>> MCMT(XGate(), 3, 1, label='foo').draw()
q_0: ──■──
│
q_1: ──■──
│
q_2: ──■──
┌─┴─┐
q_3: ┤ X ├
└───┘
>>> MCMT(XGate(), 3, 1, label='foo').name
'mcmt'
>>> MCMT(XGate(), 3, 1, label='foo').to_instruction()
<qiskit.circuit.instruction.Instruction at 0x14b031898>
>>> MCMT(XGate(), 3, 1, label='foo').to_instruction().label
>>> MCMT(XGate(), 3, 1, label='foo').to_instruction().name
'mcmt'
What is the expected behavior?
Suggested solutions
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Source code for qiskit.circuit.library.generalized_gates.mcmt
if label is not None: warnings.warn( "The MCMT 'label' kwarg is deprecated as of qiskit-terra 0.19.0 and " "will be removed no earlier...
Read more >How To Use *args and **kwargs in Python 3 - DigitalOcean
In this tutorial, we will cover the syntax of working with *args and **kwargs as parameters within functions to pass a variable number...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After some investigation, it looks like
label
is actually not ignored, though I imagine this is a bug.When multiple target qubits are used, the name of the
QuantumCircuit
created for broadcast is set to the value oflabel
. Whencontrol()
is called on the resulting gate, that name is actually eventually used in some special-casing inadd_control.py::control
.I was able to get different circuits by specifying a special-cased label.
Default (label=“2-X”)
label=“x”
@kdk
I think a label doesn’t make much sense for the MCMT since it’s not drawn as a box but as multicontrolled gate. We could make label be the label of the controlled gate, or (probably the better, cleaner solution) just remove it.