-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
controlled gates label awareness #4218
Conversation
cd7e665
to
7f3db35
Compare
I think looks fine (i'll let @ewinston take a look too). I would have preferred a leaner solution that doesn't touch all the standard gates, but seems like that's not possible because we have hardcoded what some controlled gates are (H -> CH). |
@data(*gates_and_args) | ||
@unpack | ||
def test_control_label_1(self, gate, args): | ||
"""Test gate(label=...).control(1, label=...)""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a case when num_ctrl_qubits != 1 which makes this test different than above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because control
method has special cases for num_ctrl_quits = 1
@@ -756,7 +756,7 @@ def test_open_controlled_gate(self): | |||
ctrl_state = 0 | |||
cgate = base_gate.control(num_ctrl_qubits, ctrl_state=ctrl_state) | |||
target_mat = _compute_control_matrix(base_mat, num_ctrl_qubits, ctrl_state=ctrl_state) | |||
np.set_printoptions(linewidth=200,) | |||
np.set_printoptions(linewidth=200, ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a debugging line I forgot about. Can you delete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here! #4295
Co-authored-by: Luciano Bello <luciano.bello@ibm.com>
…tandard_gates (#4035) * begin move to qiskit.circuit.gates * move more gates * move all standard gates * prepare SQU for moving not sure where to put it yet though * Move description of gates to new location Co-authored-by: Ali Javadi-Abhari <ali.javadi@ibm.com> * move new gates to circuit/gates, fix lint * new gates: dcx, iswap, rzx * fix test somehow cannot have * before u=None in SQUGate, otherwise the test_extensions_standard.test_to_matrix test fails due to a wrong num of args * return type is actually instructionset * fix tests * use circuit.gates in qiskit/ but keep old location in test * update extensions import to import form circ/gates * move equivalence lib to circuit/gates * move to library/standard_gates + kevin's comments * fix cyclic import and RST * rename leftover locations * add reno * fix cases missed in merge * Update qiskit/circuit/quantumcircuit.py Co-Authored-By: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * trailing whitespace * fix barrier import * allow gate import from qiskit.circuit * fix rxx, ryy, rzz docs (#4275) Co-authored-by: Ali Javadi-Abhari <ali.javadi@ibm.com> * fix left comments: circuit/gates to circuit/library * allow standard gate imports from circuit.library this also includes the instructions barrier, measure and reset * remove accidentally added file * add #4218 Co-authored-by: Luciano Bello <luciano.bello@ibm.com> * add #4294 Co-authored-by: Luciano Bello <luciano.bello@ibm.com> * import from new location * binding a submodule to name need py > 3.6 the circular dependency + name binding `import qiskit.circuit.library.standard_gates a gates` is only supported from python 3.7+ Co-authored-by: Ali Javadi-Abhari <ali.javadi@ibm.com> Co-authored-by: Erick Winston <ewinston@us.ibm.com> Co-authored-by: Luciano Bello <luciano.bello@ibm.com> Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…tandard_gates (Qiskit#4035) * begin move to qiskit.circuit.gates * move more gates * move all standard gates * prepare SQU for moving not sure where to put it yet though * Move description of gates to new location Co-authored-by: Ali Javadi-Abhari <ali.javadi@ibm.com> * move new gates to circuit/gates, fix lint * new gates: dcx, iswap, rzx * fix test somehow cannot have * before u=None in SQUGate, otherwise the test_extensions_standard.test_to_matrix test fails due to a wrong num of args * return type is actually instructionset * fix tests * use circuit.gates in qiskit/ but keep old location in test * update extensions import to import form circ/gates * move equivalence lib to circuit/gates * move to library/standard_gates + kevin's comments * fix cyclic import and RST * rename leftover locations * add reno * fix cases missed in merge * Update qiskit/circuit/quantumcircuit.py Co-Authored-By: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * trailing whitespace * fix barrier import * allow gate import from qiskit.circuit * fix rxx, ryy, rzz docs (Qiskit#4275) Co-authored-by: Ali Javadi-Abhari <ali.javadi@ibm.com> * fix left comments: circuit/gates to circuit/library * allow standard gate imports from circuit.library this also includes the instructions barrier, measure and reset * remove accidentally added file * add Qiskit#4218 Co-authored-by: Luciano Bello <luciano.bello@ibm.com> * add Qiskit#4294 Co-authored-by: Luciano Bello <luciano.bello@ibm.com> * import from new location * binding a submodule to name need py > 3.6 the circular dependency + name binding `import qiskit.circuit.library.standard_gates a gates` is only supported from python 3.7+ Co-authored-by: Ali Javadi-Abhari <ali.javadi@ibm.com> Co-authored-by: Erick Winston <ewinston@us.ibm.com> Co-authored-by: Luciano Bello <luciano.bello@ibm.com> Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fixes #4217
When a label is set in a controlled gate, that label should live in
controlled_gate.label
(and the same forbase_gate
)