Skip to main content

A small toolbox for physics laboratory courses at the TU Dortmund.

Project description


PyPI PyPI - Python Version PyPI - Wheel PyPI - License

Praktipy was originally designed as a small toolbox for the TU Dortmund physics laboratory course.

It contains tools for LaTeX table generation from text files and matplotlib functions to generate fitting curve plots. These python files will make your life easier when handling with human readable tables in the physik-praktikum at TU-Dortmund (, hopefully).

Table of Contents


  • python >= 3.6 with pip (other versions untested)
  • some python 3 packages, which will be installed by the install script
  • LaTeX


# Via pip (preferred)
$ pip install praktipy

# or manually
$ git clone
$ python3 install

"But I don't want to install the whole thing"

If you don't want to install the whole package on your computer, you can just download the relevant files directly:

  • Table handling: praktipy/ Just put the file into your currently used directory and import it with "import tablehandler as th"
  • Plots: Use in a similar way.

Handling tables

If you have installed the module use

import praktipy.tablehandler as th

If you just downloaded the file

import tablehandler as th

Generating tables out of text files

Praktipy uses 2-dimensional standard python-lists, to represent its lists. It can generate them out of a human readable text file (th.gen_from_txt). That seems very similar to numpy.genfromtxt, but although it is way more inefficient, it much more powerful. I can't recommend it to parse very large files (use numpy.genfromtxt for that), but every human readable table should be fine. (See benchmark notebook for details)

Why gen_from_txt is useful:

  • You can have "None" values in your table. (Holes)
  • You can have ufloats in your table. (Write them as "42.14+-6.5")
  • You can have strings in your table.
  • You can write your table visually. (gen_from_txt(filename, explicit_none=False))
  • You can write your table explicitly. (gen_from_txt(filename, explicit_none=True))
table = th.gen_from_txt("./path/to/table")
# Look what the parser has parsed

More detailed information in the source code docstrings and the /examples directory.

Generating tex tables

Once you have an 2 dimensional python list (actually it could be any 2 dimensional iterable), you can very easily make a beautiful .tex table out of it.

Why gen_tex_table is useful:

  • You can direcly \input the generated file.
  • You can split the table into subtables automaticly.
  • You can set laTeX labels and captions.
  • You can set the precision per column or globaly.
# It is that quick.
        tex_caption="Put your laTeX caption here",
        tex_label="Put your laTex label here",
        precision=["2.3", 3, "1.9"],

More detailed information in the source code docstrings and the examples directory.

Manipulating the table

You can manipulate the table with all the known python list functions. Ontop of that some functions to make your life easier are provided.

  • Tranposing table: th.transposed(table)
  • Getting the data (numbers) from the table: th.raw_data(table)
  • etc. (look in the module for further information, e.g. dir(th))

Using Matplotlib

Praktipy will try to set up the matplotlib backend to enable printing of pretty (german number format and nice math-font) plots. If you want to set up matplotlib yourself, just do that before you import anything from praktipy.

On default, praktipy will try to use a faster LaTeX setup, so your python scripts won't take too long to finish. If you indent to make nice plots and you have a little bit of time, you can use this


If you wan't to go back to the fast version again:

Important: Praktipy will set it's style file as default. If you have an existing matplotlibrc file, please make sure to merge them together. Apart from the LaTeX support, axes.formatter.use_locale : True has to be set, in order to use system locale based decimal separators (e.g. , instead of . for german)

Praktipy also provides some convenience function, for example to generate nice datapoints ontop of a fitted function.

Wildcard imports

Generally you should only import things you need in python. But nontheless it is quite handy to just import everything you need and see some code completion of things you usally need for the internship. Praktipy provides that with the wildcard import:

from praktipy import *

That will import everything you will probably need for the internship.


The code currently is not very well documented (Allthough itself provides nice Docstrings). You will find some examples in the examples directory.

Old versions

If you have already written some code with an old version of praktipy (before 2.0), it is very likely that that won't work with the new versions.

I redid the whole code style of praktipy to be a bit more pythonic.

But fear not! There is an easy trick to access old version of praktipy fro within the new version. Whenever you have written something with praktipy, like

from praktipy import *

just substitute praktipy with praktipy.legacy like that

from praktipy.legacy import *

and your code will work without problems.


Thanks a lot to PEP et al. for their Toolbox-Workshop and materials they provide. I basicly stole their matplotlib-tex-header!

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

praktipy-2.1.11.tar.gz (18.4 kB view hashes)

Uploaded source

Built Distribution

praktipy-2.1.11-py3-none-any.whl (19.8 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page