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

adding doctest #487

Merged
merged 20 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
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
9 changes: 7 additions & 2 deletions .github/workflows/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,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') && matrix.python-version == '3.9'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we testing only on Python 3.9?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can unlock to all OS and python versions. The only filtering is applied to examples which can take a long time to run.

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 @@ -46,7 +46,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 @@ -87,7 +92,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 @@ -100,7 +105,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 @@ -839,7 +844,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