Skip to content

Commit

Permalink
Merge pull request #487 from qiboteam/doctest
Browse files Browse the repository at this point in the history
adding doctest
  • Loading branch information
scarrazza committed Oct 13, 2021
2 parents 62fd271 + 4b2bec3 commit 90bb1db
Show file tree
Hide file tree
Showing 21 changed files with 303 additions and 121 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,27 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install pytest-cov
pip install .[tests]
pip install .[tests,docs]
pip install qibotf
pip install qibojit
- name: Install package on Windows
if: startsWith(matrix.os, 'windows')
run: |
python -m pip install --upgrade pip
pip install pytest-cov
pip install .[qibojit,tests]
pip install .[qibojit,tests,docs]
- name: Test with pylint
run: |
pip install pylint
pylint src -E -d E1123,E1120
- name: Test with pytest core
run: |
pytest --cov=qibo --cov-report=xml --pyargs qibo
- name: Test documentation examples
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt install pandoc
make -C doc doctest
- name: Test examples
if: startsWith(matrix.os, 'ubuntu') && matrix.python-version == '3.9'
run: |
Expand Down
13 changes: 9 additions & 4 deletions doc/source/api-reference/qibo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ Circuit addition

:class:`qibo.abstractions.circuit.AbstractCircuit` objects support addition. For example

.. code-block:: python
.. testsetup::

import qibo
qibo.set_backend("qibojit")

.. testcode::

from qibo import models
from qibo import gates
Expand Down Expand Up @@ -91,7 +96,7 @@ round starts for the target qubits of the new two-qubit gate.

For example the following:

.. code-block:: python
.. testcode::

from qibo import models, gates

Expand All @@ -104,7 +109,7 @@ For example the following:
will create a new circuit with a single :class:`qibo.abstractions.gates.FusedGate`
acting on ``(0, 1)``, while the following:

.. code-block:: python
.. testcode::

from qibo import models, gates

Expand Down Expand Up @@ -843,7 +848,7 @@ only supported by the native ``tensorflow`` backend.

The user can switch backends using

.. code-block:: python
.. testcode::

import qibo
qibo.set_backend("qibotf")
Expand Down
Loading

0 comments on commit 90bb1db

Please sign in to comment.