-
Notifications
You must be signed in to change notification settings - Fork 62
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
Fix documentation of models.circuit.Circuit
#1544
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
385867c
fix doc
renatomello 32c4700
Update src/qibo/models/circuit.py
renatomello f5b93b4
fix
renatomello 20efa95
Merge branch 'master' into fix_doc
renatomello b33ed35
merge master
renatomello 9a173f4
short command
renatomello File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,13 +120,16 @@ class Circuit: | |
A specific backend has to be used for performing calculations. | ||
|
||
Circuits can be created with a specific number of qubits and wire names. | ||
|
||
Example: | ||
.. testcode:: | ||
.. code-block:: python | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In principle, you could replace this with: Example:: The double colon is a short-cut in Sphinx for a code block, with the default syntax (which in our case, the default, it's just Python). |
||
|
||
from qibo import Circuit | ||
c = Circuit(5) # Default wire names are [0, 1, 2, 3, 4] | ||
c = Circuit(["A", "B", "C", "D", "E"]) | ||
c = Circuit(5, wire_names=["A", "B", "C", "D", "E"]) | ||
c = Circuit(wire_names=["A", "B", "C", "D", "E"]) | ||
|
||
circuit = Circuit(5) # Default wire names are [0, 1, 2, 3, 4] | ||
circuit = Circuit(["A", "B", "C", "D", "E"]) | ||
circuit = Circuit(5, wire_names=["A", "B", "C", "D", "E"]) | ||
circuit = Circuit(wire_names=["A", "B", "C", "D", "E"]) | ||
|
||
Args: | ||
nqubits (int | list, optional): Number of qubits in the circuit or a list of wire names. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just to understand: was there any issue with the
testcode
directive?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.
testcode
does not display the code in the compiled documentation, leaving the example blank in the doc https://qibo.science/qibo/stable/api-reference/qibo.html#qibo.models.circuit.Circuit + all these different initializations are being tested in the regular tests anyway.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.
Ok. I'm not sure why it is happening, since in principle even
testcode
blocks should be shown, according to Sphinxhttps://www.sphinx-doc.org/en/master/usage/extensions/doctest.html#directive-testcode
(there is an explicit attribute
:hide:
to avoid showing it).I wonder why... but a workaround is still better than an empty block. Thanks for the fix!