Explanation and examples added for various QuantumCircuit methods Fixes #3400#3683
Conversation
Co-Author: Sumit Puri <er.sumitpuri@gmail.com>
|
The examples should be in jupyter-execute blocks so as they are run at docs build time. This way errors in the docs are caught. |
|
@nonhermitian So are you suggesting to split the explanation and the example circuit? Are the one line explanations okay in these files? Can you please share a sample screenshot of where the examples need to be added? |
|
I was doing a PR for another bug #3684 but seems like it got tied to this PR instead. |
|
The explanations and examples can stay together in the same docstrings, but the example should be prefaced with |
You can revert that commit from this PR by checking out the |
…orrecting by performing 'make style'.
|
Thank you @kdk Can you help me fix the two checks that are failing. |
kdk
left a comment
There was a problem hiding this comment.
It looks like a missing import statement. This should fix it.
#3631 moved the definitions of some of the controlled gate classes into the files of their base gates (e.g. cx and ccx are now defined in x.py). Normally changes on master are automatically merged in to PR branches, but that change will have to be resolved manually. |
|
ok @kdk so what is the suggested action item for me? |
…kit-terra into sumitpuri-fixissue3640branch
Fixed (#3400) Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>
|
Thanks @kdk However, it is failing here: |
kdk
left a comment
There was a problem hiding this comment.
A few more import locations need updating.
|
Thanks @kdk all tests have passed this time. |
kdk
left a comment
There was a problem hiding this comment.
This looks just about ready to go. to_matrix was re-introduced on RZGate (maybe in one of the merge conflicts) and should be removed.
|
Hi @kdk In rz.py, there's just a to_matrix definition, not the .. jupyter-execute:: Are you suggesting to remove def to_matrix(self) code? |
Yes, it had caused a test failure earlier due to a phase difference between Rz and U1 (not sure why the test currently passes) #3683 (comment) There are some additional merge conflicts, I'll take care of removing it there. |
kdk
left a comment
There was a problem hiding this comment.
This looks good to go, thanks @sumitpuri !
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>


Summary
Fixes #3400 by adding explanations for various QuantumCircuit methods.
Details and comments
The gates (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) now have an example and explanation of what the respective gate does.