Extending mpnum

This section contains information for anyone who wishes to modify mpnum. Contributions and pull requests for mpnum are very welcome.

Code style

All warnings reported by flake8 should be fixed:

python -m flake8 .

Slightly more than 80 characters can sometimes be tolerated if reformatting would be cumbersome.

Automated unit tests

After any change to mpnum, it should be verified that automated tests succeed.

A short set of tests takes only 15 seconds and is invoked with one of

python -m pytest
python setup.py test

An intermediate set of tests takes about 2 minutes to run, is executed automatically on Travis and is invoked with one of

python -m pytest -m "not verylong"
bash tests/travis.sh

A long set of tests takes about 30 minutes and is invoked with

python -m pytest -m 1

Unit tests are implemented with pytest. Additions to mpnum should always be accompanied by unit tests.

Test coverage

Code not covered by unit tests can be detected with pytest-cov. A HTML coverage report can be generated using

python -m pytest --cov-report term --cov-report html --cov=mpnum

Afterwards, the HTML coverage report is available in htmlcov/index.html.

Building the documentation

The HTML documentation uses Sphinx. On Linux, it can be built with a simple

make -C docs html


cd docs; make html

After the build, the HTML documentation is available at docs/_build/html/index.html.

sphinx-autobuild can be used to rebuild HTML documentation automatically anytime a source file is changed:

pip install sphinx-autobuild
make -C docs livehtml

On Windows, docs/make.bat may be useful. For more information, see the Sphinx tutorial.