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

controlled gates label awareness #4218

Merged
merged 2 commits into from
Apr 27, 2020
Merged

Conversation

1ucian0
Copy link
Member

@1ucian0 1ucian0 commented Apr 22, 2020

Fixes #4217

When a label is set in a controlled gate, that label should live in controlled_gate.label (and the same for base_gate)

@1ucian0 1ucian0 marked this pull request as draft April 22, 2020 16:57
@1ucian0 1ucian0 marked this pull request as ready for review April 24, 2020 11:08
@1ucian0 1ucian0 marked this pull request as draft April 25, 2020 11:00
@1ucian0 1ucian0 marked this pull request as ready for review April 25, 2020 14:10
@1ucian0 1ucian0 added this to the 0.14 milestone Apr 25, 2020
@1ucian0 1ucian0 added the Changelog: Bugfix Include in the "Fixed" section of the changelog label Apr 25, 2020
@ajavadia
Copy link
Member

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=...)"""
Copy link
Contributor

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?

Copy link
Member Author

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, )
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here! #4295

@mergify mergify bot merged commit 2d4c755 into Qiskit:master Apr 27, 2020
Cryoris added a commit to Cryoris/qiskit-terra that referenced this pull request Apr 28, 2020
Co-authored-by: Luciano Bello <luciano.bello@ibm.com>
ajavadia added a commit that referenced this pull request Apr 28, 2020
…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>
faisaldebouni pushed a commit to faisaldebouni/qiskit-terra that referenced this pull request Aug 5, 2020
faisaldebouni pushed a commit to faisaldebouni/qiskit-terra that referenced this pull request Aug 5, 2020
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

controlled gates remove gate labels
3 participants