Skip to content
Simple and fast histogramming in python via pybind11 and OpenMP.
Branch: master
Clone or download
Latest commit 28f6c8a May 1, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.builds fix build script Mar 18, 2019
.ci-scripts fix again Apr 12, 2019
pygram11 version bump May 1, 2019
tests get rid of flow unit test code Apr 9, 2019
.clang-format formatting and docs Mar 2, 2019
.gitignore docs docs docs Mar 4, 2019
LICENSE bring to git Feb 1, 2019 Add tests to Mar 16, 2019 readme wording Apr 29, 2019
readthedocs.yml docs, installation on macOS outside of conda Feb 7, 2019
requirements.txt bring to git Feb 1, 2019 change development status Apr 20, 2019

pygram11 status Documentation Status PyPI version Conda Forge DOI Code style: black

Simple and fast histogramming in python via pybind11 and (optionally) OpenMP.

pygram11 provides fast functions for calculating histograms (and their sums-of-weights squared). The API is very simple, check out the documentation (you'll also find some benchmarks there) and my blog post.


pygram11 requires only NumPy and pybind11 (and therefore a C++ compiler with C++11 support).

From conda-forge

conda install pygram11 -c conda-forge

Builds on conda-forge will have OpenMP available.

From PyPI

Note: When using PyPI (or source), pybind11 must be installed explicitly before pygram11 (because uses pybind11 to determine include directories; not an issue if using the conda-forge build).

$ pip install pybind11 ## or `conda install pybind11`
$ pip install pygram11

From Source

$ git clone
$ pip install pybind11
$ cd pygram11
$ pip install .

In Action

A fixed bin width histogram of weighted data in one dimension, accelerated with OpenMP:

>>> x = np.random.randn(10000)
>>> w = np.random.uniform(0.8, 1.2, 10000)
>>> h, sw2 = pygram11.histogram(x, bins=40, range=(-4, 4), weights=w, omp=True)
>>> stat_err = np.sqrt(sw2)

A variable bin width histogram in two dimensions:

>>> x = np.random.randn(10000)
>>> y = np.random.randn(10000)
>>> xbins = [-2.0, -1.0, -0.5, 1.5, 2.0]
>>> ybins = [-3.0, -1.5, -0.1, 0.8, 2.0]
>>> h = pygram11.histogram2d(x, y, bins=[xbins, ybins])

If there is something you'd like to see in pygram11, please open an issue or pull request.

You can’t perform that action at this time.