Pweave - Scientific Reports Using Python

Pweave is a scientific report generator and a literate programming tool for Python. Pweave can capture the results and plots from data analysis and works well with NumPy, SciPy and matplotlib. It is able to run python code from source document and include the results and capture matplotlib plots in the output.

It can produce reST, Sphinx, Latex, HTML and markdown (pandoc and leanpub) output from several input formats.

  • Noweb uses noweb syntax for separating code from documentation.
  • Markdown. Run code from markdown code blocks.
  • Script. Python script with special markup in comments. See: publishing scripts.

Pweave is good for creating reports, tutorials, presentations etc. with embedded python code It can also be used to make websites together with e.g. Sphinx or rest2web.

Warning

Note: pip install of Pweave fails in Python 3. This is due to a bug in pip. You’ll need to use “conda”, “easy install” or download the source and run python setup.py install.

Note

Report bugs on Github. Post your questions and comments to Pweave google group.

Features:

  • Python 2.7, 3.4 and 3.5 compatibility
  • Execute python code in the chunks and capture input and output to a report.
  • Use hidden code chunks, i.e. code is executed, but not printed in the output file.
  • Capture matplotlib graphics.
  • Evaluate inline code in documentation chunks marked using <% %> and <%= %>.
  • Cache all code and results from previous runs for fast report generation when you are only working with documentation. Inline code will be hidden in documentation mode.
  • Supports reST, LaTeX, HTML or markdown for document chunks
  • Publish reports from Python scipts. Similar to R markdown.
  • Run from command line or interpreter.
  • Support also for Octave and Matlab code.

Install and quickstart:

with pip:

pip install --upgrade Pweave

with conda:

conda config --add channels mpastell
conda install pweave

Or download the source package from PyPi and run:

python setup.py install

After the installation you get options with:

$ pweave --help
$ ptangle

Documentation

Browse documentation or go straight to an examples

Thanks

Pweave was originally inspired by Sweave, an excellent tool for R programmers. The current version has also been influenced by ideas from knitr and R markdown.

Thanks to following people for contributing patches and ideas: Jakub Kowalski, Tamas Nepusz, Nicky van Foreest, Mark Edgington, Thomas Unterthiner, Matthew McDonald, Grant Goodyear, Aaron O’Leary, Thomas Saunders .