unitaryfund / mitiq

Mitiq is an open source toolkit for implementing error mitigation techniques on most current intermediate-scale quantum computers.
https://mitiq.readthedocs.io
GNU General Public License v3.0
363 stars 160 forks source link

Some documentation is not being tested in CI #766

Closed rmlarose closed 3 years ago

rmlarose commented 3 years ago

If you copy-paste the IBMQ example into a colab, there is an error.

image

(Should be from mitiq import zne instead of import mitiq above.)

We should be testing examples in CI to make sure they run and catch errors like this.

nathanshammah commented 3 years ago

We are running the tests on the documentation: https://github.com/unitaryfund/mitiq/blob/58fdff01d53c0b9cf9b068d60e005c094ca6ffcb/.github/workflows/test.yml#L52

In the user guide, we have 76 testcode directive instances. .

The way myst works is by building the docs by running the notebooks (be them rst or other formats), so all output seen in the html documentation online has been generated by some code, and this happens also in CI.

The instructions to include test code directives in .rst are shown in the [Testing example] (https://mitiq.readthedocs.io/en/stable/examples/test.html#testing) and here in the code: https://github.com/unitaryfund/mitiq/blob/master/docs/source/examples/test.myst#L159-L173 that is not shown.

The reason why this import issue is not picked up may be due to a global requirement that is set in the conf.py, which sets an alias import, https://github.com/unitaryfund/mitiq/blob/255df184eca7a1b3e60455c281c3b884719ff876/docs/source/conf.py#L157-L168. We could remove that.

rmlarose commented 3 years ago

Thanks for noting the global config. I removed it in #804 to test and the docs build passes, so there is something else going on.

andreamari commented 3 years ago

The problem seems to be related to using .. testcode:: python instead of just .. testcode:: . See last commit [test] try removing "python" style label of #804 (i.e. 9bcb927) .

rmlarose commented 3 years ago

Thanks @andreamari. There's a lot of other .. testcode:: python directives in that file, I guess those should be removed as well...?