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

MPL drawer CU1 gate is inconsistent with other drawers #3684

Closed
sumitpuri opened this issue Jan 5, 2020 · 4 comments · Fixed by #3709
Closed

MPL drawer CU1 gate is inconsistent with other drawers #3684

sumitpuri opened this issue Jan 5, 2020 · 4 comments · Fixed by #3709
Assignees
Labels
bug Something isn't working priority: medium

Comments

@sumitpuri
Copy link
Contributor

Information

  • Qiskit Terra version: 0.11.0
  • Python version: 3.7
  • Operating system: Mac OS 10.15.1

What is the current behavior?

circuit = QuantumCircuit(2)
theta = numpy.pi/2
circuit.cu1(theta,0,1)
circuit.draw()

Output-

q_0: |0>─■─────
         │pi/2 
q_1: |0>─■─────

However, mpl shows fine-
image

Steps to reproduce the problem

Paste the above code in Jupyter notebook and run.

What is the expected behavior?

The text drawer should show up like this-

q_0: |0>─────■──────
        ┌────┴─────┐
q_1: |0>┤ U1(pi/2) ├
        └──────────┘

Suggested solutions

Fix is provided below in the PR by making changes in qiskit/visualization/text.py

@ajavadia
Copy link
Member

ajavadia commented Jan 7, 2020

Thanks for bringing up the inconsistency. This was supposed to have been fixed via #1957 (and PR #2254). Seems like a regression.

However note that the text drawer is correct here. CU1 is a symmetric gate and thus a typical notation to signify this is to draw control/target the same. So mpl drawer should be fixed.

@ajavadia ajavadia changed the title Circuit Text Drawer does not draw cU1 gate correctly MPL drawer CU1 gate is inconsistent with other drawers Jan 7, 2020
@sumitpuri
Copy link
Contributor Author

Got it, I will fix the MPL Drawer.

@sumitpuri
Copy link
Contributor Author

@ajavadia Does this look right?

Also, I am already working on a different bug and have a PR open. Whenever I push my changes for this bug, the changes get tied to that already opened PR. How can I push so that it creates a new PR related to this bug?

image

@1ucian0
Copy link
Member

1ucian0 commented Jan 11, 2020

The results looks correct!

About the git issue, I think the problem is that you have to put different fixes in different branches (all from master). You can create different PRs from them.

@1ucian0 1ucian0 added this to To do in Visualization and Juypter Tools via automation Jan 11, 2020
@kdk kdk closed this as completed in 1de26bb Feb 6, 2020
Visualization and Juypter Tools automation moved this from To do to Done Feb 6, 2020
@kdk kdk reopened this Feb 6, 2020
Visualization and Juypter Tools automation moved this from Done to To do Feb 6, 2020
@mergify mergify bot closed this as completed in #3709 Feb 20, 2020
Visualization and Juypter Tools automation moved this from To do to Done Feb 20, 2020
mergify bot pushed a commit that referenced this issue Feb 20, 2020
* Fixed issue 3640 by adding logic for complex imaginary numbers

Co-Author: Sumit Puri <er.sumitpuri@gmail.com>

* Added test for display of 'pi'.

* Added test for displaying 'pi' for both real and imaginary parts of complex number.

* Release notes added for Fixes #3640

* release notes

* Fixes #3400

Examples have been provided for the following methods- ccx, ch, crz, cswap, cu1, cu3, cx, cy, cz, h, iden, rx, ry, rz, s, sdg, swap, t, tdg, u1, u2, u3, x, y, z

* Revert "Fixes #3400"

This reverts commit 36b7881.

* Fixes #3400

Examples have been provided for the following methods- ccx, ch, crz, cswap, cu1, cu3, cx, cy, cz, h, iden, rx, ry, rz, s, sdg, swap, t, tdg, u1, u2, u3, x, y, z

* Added release notes for Fixes #3400

* Fixes #3684 Text drawer displays cU1 correctly.

* Revert "Fixes #3684 Text drawer displays cU1 correctly."

This reverts commit b8b010e.

* Fixes #3400 by adding jupyter-execute statement in the examples.

* Fixes #3400 by adding jupyter-execute statement in the examples and correcting by performing 'make style'.

* Update qiskit/extensions/standard/crz.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Revert "Update qiskit/extensions/standard/crz.py"

This reverts commit 2abc824.

* Fixes #3400 Added import numpy

* #3400 added import numpy statements

* Fixes #3684

* Release notes for #3684 fixes

* Fixes #3400 incorporated comments from @nonhermitian

* Fixes #3400 added more text.

* Update qiskit/extensions/standard/rx.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Added params for matrix generation.

* Removed Matrix representation from rz.py

* Update qiskit/extensions/standard/z.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/y.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/y.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/u2.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/cx.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/u3.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Fixes #3400 incorporated suggestions

* Fixes #3400 H gate description.

* Added matrix for cswap

* Consistency with removing hyphen.

* Fixes #3400 consistency

* Fixing style

* Rearranged the import order

* Fixes matrix representation

* Incorporating suggestions

* Incorporated comments (#3400)

* Update qiskit/extensions/standard/swap.py

Fixed (#3400)

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/h.py

Fixed (#3400)

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/swap.py

Fixed (#3400)

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/x.py

Fixed (#3400)

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Fix lint failures following merge resolution.

* Delete fix3400_quantum_methods-e822a1247329f927.yaml

This reno belongs to a different PR

Co-authored-by: Luciano Bello <luciano.bello@ibm.com>
Co-authored-by: Kevin Krsulich <kevin@krsulich.net>
faisaldebouni pushed a commit to faisaldebouni/qiskit-terra that referenced this issue Aug 5, 2020
Qiskit#3400 (Qiskit#3683)

* Fixed issue 3640 by adding logic for complex imaginary numbers

Co-Author: Sumit Puri <er.sumitpuri@gmail.com>

* Added test for display of 'pi'.

* Added test for displaying 'pi' for both real and imaginary parts of complex number.

* Release notes added for Fixes Qiskit#3640

* release notes

* Fixes Qiskit#3400

Examples have been provided for the following methods- ccx, ch, crz, cswap, cu1, cu3, cx, cy, cz, h, iden, rx, ry, rz, s, sdg, swap, t, tdg, u1, u2, u3, x, y, z

* Revert "Fixes Qiskit#3400"

This reverts commit 36b7881.

* Fixes Qiskit#3400

Examples have been provided for the following methods- ccx, ch, crz, cswap, cu1, cu3, cx, cy, cz, h, iden, rx, ry, rz, s, sdg, swap, t, tdg, u1, u2, u3, x, y, z

* Added release notes for Fixes Qiskit#3400

* Fixes Qiskit#3684 Text drawer displays cU1 correctly.

* Revert "Fixes Qiskit#3684 Text drawer displays cU1 correctly."

This reverts commit b8b010e.

* Fixes Qiskit#3400 by adding jupyter-execute statement in the examples.

* Fixes Qiskit#3400 by adding jupyter-execute statement in the examples and correcting by performing 'make style'.

* Update qiskit/extensions/standard/crz.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Revert "Update qiskit/extensions/standard/crz.py"

This reverts commit 2abc824.

* Fixes Qiskit#3400 Added import numpy

* Qiskit#3400 added import numpy statements

* Fixes Qiskit#3400 incorporated comments from @nonhermitian

* Fixes Qiskit#3400 added more text.

* Update qiskit/extensions/standard/rx.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Added params for matrix generation.

* Removed Matrix representation from rz.py

* Update qiskit/extensions/standard/z.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/y.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/y.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/u2.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/cx.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/u3.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Fixes Qiskit#3400 incorporated suggestions

* Fixes Qiskit#3400 H gate description.

* Added matrix for cswap

* Consistency with removing hyphen.

* Fixes Qiskit#3400 consistency

* Fixing style

* Rearranged the import order

* Fixes matrix representation

* Incorporating suggestions

* Incorporated comments (Qiskit#3400)

* Update qiskit/extensions/standard/swap.py

Fixed (Qiskit#3400)

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/h.py

Fixed (Qiskit#3400)

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/swap.py

Fixed (Qiskit#3400)

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/x.py

Fixed (Qiskit#3400)

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Fix lint failures following merge resolution.

Co-authored-by: Luciano Bello <luciano.bello@ibm.com>
Co-authored-by: Kevin Krsulich <kevin@krsulich.net>
faisaldebouni pushed a commit to faisaldebouni/qiskit-terra that referenced this issue Aug 5, 2020
* Fixed issue 3640 by adding logic for complex imaginary numbers

Co-Author: Sumit Puri <er.sumitpuri@gmail.com>

* Added test for display of 'pi'.

* Added test for displaying 'pi' for both real and imaginary parts of complex number.

* Release notes added for Fixes Qiskit#3640

* release notes

* Fixes Qiskit#3400

Examples have been provided for the following methods- ccx, ch, crz, cswap, cu1, cu3, cx, cy, cz, h, iden, rx, ry, rz, s, sdg, swap, t, tdg, u1, u2, u3, x, y, z

* Revert "Fixes Qiskit#3400"

This reverts commit 36b7881.

* Fixes Qiskit#3400

Examples have been provided for the following methods- ccx, ch, crz, cswap, cu1, cu3, cx, cy, cz, h, iden, rx, ry, rz, s, sdg, swap, t, tdg, u1, u2, u3, x, y, z

* Added release notes for Fixes Qiskit#3400

* Fixes Qiskit#3684 Text drawer displays cU1 correctly.

* Revert "Fixes Qiskit#3684 Text drawer displays cU1 correctly."

This reverts commit b8b010e.

* Fixes Qiskit#3400 by adding jupyter-execute statement in the examples.

* Fixes Qiskit#3400 by adding jupyter-execute statement in the examples and correcting by performing 'make style'.

* Update qiskit/extensions/standard/crz.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Revert "Update qiskit/extensions/standard/crz.py"

This reverts commit 2abc824.

* Fixes Qiskit#3400 Added import numpy

* Qiskit#3400 added import numpy statements

* Fixes Qiskit#3684

* Release notes for Qiskit#3684 fixes

* Fixes Qiskit#3400 incorporated comments from @nonhermitian

* Fixes Qiskit#3400 added more text.

* Update qiskit/extensions/standard/rx.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Added params for matrix generation.

* Removed Matrix representation from rz.py

* Update qiskit/extensions/standard/z.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/y.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/y.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/u2.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/cx.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/u3.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Fixes Qiskit#3400 incorporated suggestions

* Fixes Qiskit#3400 H gate description.

* Added matrix for cswap

* Consistency with removing hyphen.

* Fixes Qiskit#3400 consistency

* Fixing style

* Rearranged the import order

* Fixes matrix representation

* Incorporating suggestions

* Incorporated comments (Qiskit#3400)

* Update qiskit/extensions/standard/swap.py

Fixed (Qiskit#3400)

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/h.py

Fixed (Qiskit#3400)

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/swap.py

Fixed (Qiskit#3400)

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/x.py

Fixed (Qiskit#3400)

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Fix lint failures following merge resolution.

* Delete fix3400_quantum_methods-e822a1247329f927.yaml

This reno belongs to a different PR

Co-authored-by: Luciano Bello <luciano.bello@ibm.com>
Co-authored-by: Kevin Krsulich <kevin@krsulich.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: medium
Development

Successfully merging a pull request may close this issue.

4 participants