-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add examples for the NLocal
class docstrings (#9080)
#9302
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
base: main
Are you sure you want to change the base?
Conversation
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 |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 🙂
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.
Sure
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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.
Sounds OK, Removing.
Hello @ohadlev77 ! are you still working on this PR? |
Summary
This PR fixes issue #9080 by adding 2 examples for using the
NLocal
class.Details and comments
I have added 2 examples for using the
NLocal
class that emphasize the necessary aspects.Example 1 uses pre-defined
QuantumCircuit
objects for the rotation and entanglement layers.Example 2 demonstrates the specific interface of the
NLocal
class compared to other parameterized circuit classes (e.gTwoLocal
orEfficiensSU2
) - one needs to provide the actual gate objects for therotation_blocks
/entanglement_blocks
arguments (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
import
statements 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.