elephant icon indicating copy to clipboard operation
elephant copied to clipboard

Fix/doctests

Open Moritz-Alexander-Kern opened this issue 2 years ago • 1 comments

doctests

The doctest module looks for such sequences of prompts in a docstring, re-executes the extracted command and checks the output against the output of the command given in the docstrings test example.

Many doctrings in elephant contain code examples using the following syntax:

  • When using the Python shell, the primary prompt: >>> , is followed by new commands.
  • The secondary prompt: ... , is used when continuing commands on multiple lines; and the result of executing the command is expected on following lines.
  • A blank line, or another line starting with the primary prompt is seen as the end of the output from the command.

So far elephant has no standardized form for doctests, which means, that some examples e.g. contain figures or don't produce any result. In those cases running doctests executes those examples and checks for errors, but does not check the results.

With this PR errors occurring during doctests are fixed and further steps aim to make doctests part of the Cx workflow.

This PR could be the starting point to establish doctests as a standard in elephant.

run only doctests

pytest elephant --doctest-modules --ignore=elephant/test/

todo:

  • [x] create CI workflow to execute doctests, done, see #503
  • [x] split this PR into multiple parts, part 1: fixes that only require reformatting, done, see #502

Moritz-Alexander-Kern avatar Jun 23 '22 07:06 Moritz-Alexander-Kern

Hello @Moritz-Alexander-Kern! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers:

Comment last updated at 2022-06-23 07:30:31 UTC

pep8speaks avatar Jun 23 '22 07:06 pep8speaks

This Pr was split in 2 parts and is done

Moritz-Alexander-Kern avatar Feb 16 '23 10:02 Moritz-Alexander-Kern