Skip to main content

Fast histogramming in Python built on pybind11 and OpenMP.

Project description

pygram11

Documentation Status Actions Status builds.sr.ht status PyPI version Conda Forge Python Version

Simple and fast histogramming in Python accelerated with OpenMP (with help from pybind11).

pygram11 provides fast functions for calculating histograms (and the variance in each bin). The API is very simple; documentation can be found here (you'll also find some benchmarks there).

Installing

Python 3 releases supported by both pybind11 and NumPy should be compatible with pygram11. Python version 3.6 (or later) and NumPy version 1.16+ are supported by tests (and have binary releases). To build and install from source you'll just need a compiler with support for C++11 and OpenMP. The only runtime dependency is NumPy.

From PyPI

Binary wheels are provided for Linux and macOS. They can be installed from PyPI via pip.

pip install pygram11

From conda-forge

For installation via the conda package manager pygram11 is part of conda-forge.

conda install pygram11 -c conda-forge

Please note that on macOS the OpenMP libraries from LLVM (libomp) and Intel (libiomp) may clash if your conda environment includes the Intel Math Kernel Library (MKL) package distributed by Anaconda. You may need to install the nomkl package to prevent the clash (Intel MKL accelerates many linear algebra operations, but does not impact pygram11):

conda install nomkl ## sometimes necessary fix (macOS only)

From Source

All you need is a C++11 compiler and OpenMP. If you are using a relatively modern GCC release on Linux then you probably don't have to worry about the OpenMP dependency. If you are on macOS, you can install libomp from Homebrew. With those dependencies met, simply run:

pip install git+https://github.com/douglasdavis/pygram11.git@master

In Action

A histogram (with fixed bin width) of weighted data in one dimension:

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

A histogram with fixed bin width which saves the under and overflow in the first and last bins:

>>> x = np.random.randn(1000000)
>>> h, err = pygram11.histogram(x, bins=20, range=(-3, 3), flow=True)

A histogram in two dimensions with variable width bins:

>>> 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, err = pygram11.histogram2d(x, y, bins=[xbins, ybins])

Histogramming multiple weight variations for the same data, then putting the result in a DataFrame (the input pandas DataFrame will be interpreted as a NumPy array):

>>> weights = pd.DataFrame({"weight_a" : np.abs(np.random.randn(10000)),
...                         "weight_b" : np.random.uniform(0.5, 0.8, 10000),
...                         "weight_c" : np.random.rand(10000)})
>>> data = np.random.randn(10000)
>>> count, err = pygram11.histogram(data, bins=20, range=(-3, 3), weights=weights, flow=True)
>>> count_df = pd.DataFrame(count, columns=weights.columns)
>>> err_df = pd.DataFrame(err, columns=weights.columns)

I also wrote a blog post with some simple examples.

Other Libraries

  • There is an effort to develop an object oriented histogramming library for Python called boost-histogram. This library will be feature complete w.r.t. everything a physicist needs with histograms.
  • Simple and fast histogramming in Python using the NumPy C API: fast-histogram (no variance or overflow support).
  • If you want to calculate histograms on a GPU in Python, check out cupy.histogram. They only have 1D histograms (no weights or overflow).

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

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

pygram11-0.10.3.tar.gz (808.4 kB view details)

Uploaded Source

Built Distributions

pygram11-0.10.3-cp39-cp39-manylinux2010_x86_64.whl (266.7 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

pygram11-0.10.3-cp39-cp39-manylinux2010_i686.whl (283.8 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

pygram11-0.10.3-cp39-cp39-macosx_10_9_x86_64.whl (402.5 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pygram11-0.10.3-cp38-cp38-manylinux2010_x86_64.whl (266.8 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

pygram11-0.10.3-cp38-cp38-manylinux2010_i686.whl (283.8 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

pygram11-0.10.3-cp38-cp38-macosx_10_9_x86_64.whl (402.9 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

pygram11-0.10.3-cp37-cp37m-manylinux2010_x86_64.whl (265.4 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

pygram11-0.10.3-cp37-cp37m-manylinux2010_i686.whl (281.1 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

pygram11-0.10.3-cp37-cp37m-macosx_10_9_x86_64.whl (398.8 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

pygram11-0.10.3-cp36-cp36m-manylinux2010_x86_64.whl (265.3 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

pygram11-0.10.3-cp36-cp36m-manylinux2010_i686.whl (281.0 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

pygram11-0.10.3-cp36-cp36m-macosx_10_9_x86_64.whl (398.8 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

Details for the file pygram11-0.10.3.tar.gz.

File metadata

  • Download URL: pygram11-0.10.3.tar.gz
  • Upload date:
  • Size: 808.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pygram11-0.10.3.tar.gz
Algorithm Hash digest
SHA256 b90f62ce97158d6208889eed43c1b494cfedda0c339f82cbaf83ce9d4ecb350c
MD5 dfd4479038c1c8911b9e3f368d3b61a5
BLAKE2b-256 c718e8640d401d838b07b5f8897834a8590252af3c7d837d7bbad713ac042383

See more details on using hashes here.

File details

Details for the file pygram11-0.10.3-cp39-cp39-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pygram11-0.10.3-cp39-cp39-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 266.7 kB
  • Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pygram11-0.10.3-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 9e56b8904bd2a8be121eacaee273d549b204ecaf04357665fd88c65f36b7b64a
MD5 71650fa65da715d0ad790385f06da1f2
BLAKE2b-256 553691a01878c5a7fd4e7e2aa7a13900ee1b4b632be098725737d22b1f135d1e

See more details on using hashes here.

File details

Details for the file pygram11-0.10.3-cp39-cp39-manylinux2010_i686.whl.

File metadata

  • Download URL: pygram11-0.10.3-cp39-cp39-manylinux2010_i686.whl
  • Upload date:
  • Size: 283.8 kB
  • Tags: CPython 3.9, manylinux: glibc 2.12+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pygram11-0.10.3-cp39-cp39-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 ef6edd8482207c8f3be86a72e93748307be301bb7c83db24896443a9fe285f03
MD5 d5d7014417319f7f782a5f0882f2d0d9
BLAKE2b-256 35f4ed602ac041579202ee6c4921a70a0d85b39a37d8da409ab0d5f5139a6ef3

See more details on using hashes here.

File details

Details for the file pygram11-0.10.3-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: pygram11-0.10.3-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 402.5 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pygram11-0.10.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4888906e6b61eb63ef8f51661472e70dd191ca12d273c8b56a7b88d5ce899b01
MD5 cd8baaa2eff7a31dc6165f50eec45d6b
BLAKE2b-256 84dae9670968d7c2c654aaf0d0240476b8025045ccaec80fef9dc28cfd6783fc

See more details on using hashes here.

File details

Details for the file pygram11-0.10.3-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pygram11-0.10.3-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 266.8 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pygram11-0.10.3-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 f7fe548c082d2d9f3b0cec41b542f3a994a26e59a687dde09d5a54dcdaa5e8c8
MD5 394acb3e22c315d5bae12765c7fde75f
BLAKE2b-256 8baba7c83ddebbc845941c15c0a05182261c176c43000e8402bd849b06a023fe

See more details on using hashes here.

File details

Details for the file pygram11-0.10.3-cp38-cp38-manylinux2010_i686.whl.

File metadata

  • Download URL: pygram11-0.10.3-cp38-cp38-manylinux2010_i686.whl
  • Upload date:
  • Size: 283.8 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pygram11-0.10.3-cp38-cp38-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 f690f1afa9caa528d75f434d66c2967f29f023d1869827f49915e3ac1735010d
MD5 ab24a21a25b4ec379aa00ba754af2fc1
BLAKE2b-256 4dcc4f294f3cbb62118d77289c4f98bc9ca3e458ba11bb1032195e86045ea407

See more details on using hashes here.

File details

Details for the file pygram11-0.10.3-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: pygram11-0.10.3-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 402.9 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pygram11-0.10.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 411e7819724596da448adf3ae2cf946842cc1433ca83d1925e28f767b9ca19e1
MD5 46026fa8808995f18370906a8083b0c0
BLAKE2b-256 c5849563774e74bb0a7e7a58c920b43172c118ab23af5399a20c0a5bca24466b

See more details on using hashes here.

File details

Details for the file pygram11-0.10.3-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pygram11-0.10.3-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 265.4 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pygram11-0.10.3-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 69539b1142ec12698a6df3381d3a3e643e77322e3e5ae74c20a90793aeb8afe7
MD5 0102904ac3ae1802f29d749a3ea336db
BLAKE2b-256 43d039ef4c13e322fd3ab422db34c177b8a6c58c756a3051d0c249242e871df5

See more details on using hashes here.

File details

Details for the file pygram11-0.10.3-cp37-cp37m-manylinux2010_i686.whl.

File metadata

  • Download URL: pygram11-0.10.3-cp37-cp37m-manylinux2010_i686.whl
  • Upload date:
  • Size: 281.1 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pygram11-0.10.3-cp37-cp37m-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 6a7128a27665781ddb5294a9626fb1527d166df48548f66411b0c7751a86ff70
MD5 742a9e444a4e28dce3ea8b4596b2717f
BLAKE2b-256 fca1f78223c76fa9bcff43ef76b4a3eb1a78460c98a21133b8a0afaffe52405c

See more details on using hashes here.

File details

Details for the file pygram11-0.10.3-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: pygram11-0.10.3-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 398.8 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pygram11-0.10.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 498fe8b55f51d5a035b5a49746f1de37a02efae4a5b3fae244ea195a9e889310
MD5 95c9c2837e891aa7dbdb8e3e1d42b84a
BLAKE2b-256 8b96e9cf1535646d1a4c4ce2cd388f2df7a1b17c1b2ae3db21fab9969a8d23b2

See more details on using hashes here.

File details

Details for the file pygram11-0.10.3-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pygram11-0.10.3-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 265.3 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pygram11-0.10.3-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 f5dcbdb1477021e221177337661e3489ed7bf46216a00163766939b33d918188
MD5 659151d7f125143fe09a1df166568e39
BLAKE2b-256 bd21041130cb486b1a699d74166fb3456e7a3b8c6826235148d064c3e52111e5

See more details on using hashes here.

File details

Details for the file pygram11-0.10.3-cp36-cp36m-manylinux2010_i686.whl.

File metadata

  • Download URL: pygram11-0.10.3-cp36-cp36m-manylinux2010_i686.whl
  • Upload date:
  • Size: 281.0 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pygram11-0.10.3-cp36-cp36m-manylinux2010_i686.whl
Algorithm Hash digest
SHA256 5a549ae996aed4c9f5910656248056d6b97428c93ee55ed285ca39fac8fbb974
MD5 b28164ad18abde3da61edeca41a8f9e6
BLAKE2b-256 6f64fc5c93dafa83781e051d9ee19a840c819b741a0ccf9dac3d6c1945a10837

See more details on using hashes here.

File details

Details for the file pygram11-0.10.3-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: pygram11-0.10.3-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 398.8 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for pygram11-0.10.3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 eeb9a80185ec09160ad5ac6287e81b8e1d7534f79c3490dd9b2645160039151b
MD5 e287fde25a08b77c0cd6e9109e023c3c
BLAKE2b-256 b20f4595f0c1462bc58bc2fcc8e7da1e0f3ff0211575cc7e3fdc003a1ecfab38

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page