Add examples for the NLocal class docstrings (#9080)#9302
Add examples for the NLocal class docstrings (#9080)#9302ohadlev77 wants to merge 3 commits intoQiskit:mainfrom
NLocal class docstrings (#9080)#9302Conversation
|
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this: |
9408aaf to
b2b2fda
Compare
|
@ohadlev77 I think you are right. The failing Python 3.11 is not due to your code. See #9296 |
HuangJunye
left a comment
There was a problem hiding this comment.
Can you please put the code inside jupyter-execute directives so that the code can be executed and tested during the building process?
b2b2fda to
ff43207
Compare
|
@HuangJunye |
|
@HuangJunye can you please check the PR? |
|
@ohadlev77 As discussed via Slack, we have removed the usage of |
| # Example 1: | ||
| # "Blocks" are defined by `QuantumCircuit` objects. | ||
| # The "basic rotation block" consists of a 1-depth 2-qubits `QuantumCircuit` object. | ||
| # The "basic entanglement block" consists of a 3-depth 4-qubits `QuantumCircuit` object. | ||
| # Every "rotation layer" consists of a vertical repetition over the basic rotation block. | ||
| # Every "entanglement layer" consists of a `linear` repetition over | ||
| # the basic entanglement block. |
There was a problem hiding this comment.
I think you could move this explanation outside of the code block, then it would be rendered as normal text and be easier to read 🙂
| # In the following `***_blocks` arguments is necessary to specify the actual gate objects, | ||
| # rather than some abbreviations that are used in other classes, | ||
| # e.g `CZGate()` = right, `cz` = wrong. |
There was a problem hiding this comment.
If users are not familiar with specification per string, I think this is more confusing than clarifying. How about just removing that subsentence? 🙂
| # In the following `***_blocks` arguments is necessary to specify the actual gate objects, | |
| # rather than some abbreviations that are used in other classes, | |
| # e.g `CZGate()` = right, `cz` = wrong. | |
| # In the following `***_blocks` arguments is necessary to specify the Gate objects |
|
Hello @ohadlev77 ! are you still working on this PR? |
Summary
This PR fixes issue #9080 by adding 2 examples for using the
NLocalclass.Details and comments
I have added 2 examples for using the
NLocalclass that emphasize the necessary aspects.Example 1 uses pre-defined
QuantumCircuitobjects for the rotation and entanglement layers.Example 2 demonstrates the specific interface of the
NLocalclass compared to other parameterized circuit classes (e.gTwoLocalorEfficiensSU2) - one needs to provide the actual gate objects for therotation_blocks/entanglement_blocksarguments (e.gRYGate(),RXGate(), etc). In the case of the other parameterized circuit classes, one can specify a specific string for a desired gate object (e.g'ry'for an RY gate).Following the convention in the docstrings of the other parameterized circuit classes, I didn't include any
importstatements within the examples. Of course, it can be done if we desire this, but I preferred to stick with the current convention that I've observed.