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

Fix documentation of models.circuit.Circuit #1544

Merged
merged 6 commits into from
Dec 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/qibo/models/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,12 @@ 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
Copy link
Member

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?

Copy link
Contributor Author

@renatomello renatomello Dec 16, 2024

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.

Copy link
Member

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 Sphinx
https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html#directive-testcode

By default it is shown as a highlighted code block.

(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!

Copy link
Member

Choose a reason for hiding this comment

The 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).
https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#literal-blocks


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"])
Expand Down
Loading