Skip to main content

Fast histogramming in python built on pybind11 and OpenMP.

Project description

pygram11

builds.sr.ht status Documentation Status PyPI version Conda Forge Code style: black

Simple and fast histogramming in Python via pybind11 and accelerated with OpenMP.

pygram11 provides fast functions for calculating histograms (and their sums-of-weights squared). The API is very simple, documentation found here (you'll also find some benchmarks there). I also wrote a blog post with some simple examples.

Installing

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

From conda-forge

For a simple installation process via the conda package manager pygram11 is part of conda-forge. These builds include OpenMP acceleration.

conda install pygram11 -c conda-forge

From PyPI

Binary wheels are provided for Linux and macOS, they can be installed from PyPI via pip. These builds include OpenMP acceleration.

pip install pygram11

From Source

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

Note: For releases older than v0.5, when building from source or PyPI, pybind11 was required to be explicitly installed before pygram11 (because setup.py used pybind11 to determine include directories). Starting with v0.5 pybind11 is bundled with the source for non-binary (conda-forge or wheel) installations.

In Action

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

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

A histogram with fixed bin width which saves the under and overflow in the first and last bins (using __ to catch the None returned due to the absence of weights):

>>> x = np.random.randn(1000000)
>>> h, __ = pygram11.histogram(x, bins=20, range=(-3, 3), flow=True, omp=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, __ = pygram11.histogram2d(x, y, bins=[xbins, ybins])

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 weights or overflow).
  • If you want to calculate histograms on a GPU in Python, check out cupy.histogram. They only have 1D histograms (no weights over 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.5.0.tar.gz (145.8 kB view details)

Uploaded Source

Built Distributions

pygram11-0.5.0-cp37-cp37m-manylinux2010_x86_64.whl (1.3 MB view details)

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

pygram11-0.5.0-cp37-cp37m-manylinux1_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.7m

pygram11-0.5.0-cp36-cp36m-manylinux2010_x86_64.whl (1.3 MB view details)

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

pygram11-0.5.0-cp36-cp36m-manylinux1_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.6m

pygram11-0.5.0-cp27-cp27m-manylinux2010_x86_64.whl (1.3 MB view details)

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

pygram11-0.5.0-cp27-cp27m-manylinux1_x86_64.whl (1.5 MB view details)

Uploaded CPython 2.7m

File details

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

File metadata

  • Download URL: pygram11-0.5.0.tar.gz
  • Upload date:
  • Size: 145.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for pygram11-0.5.0.tar.gz
Algorithm Hash digest
SHA256 de872baef0213e4101daf7d46baaac620b7efd0bbc427d662db72303304a24b3
MD5 c32ba31db4f05fa5a6eebf97c9eae66f
BLAKE2b-256 8ee98d9df9d8861ab2d44f33eae6d8ae748285afd7f698d6eed9fe783cbf9ef4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygram11-0.5.0-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for pygram11-0.5.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 38cb509fda29e28de3c4207f5ceb1deedfaf861de1bc93bf8426767dd3ec322c
MD5 a0e28c666f2ddc6f6cc74c1f3d16ebe9
BLAKE2b-256 b2481c7b43d4fb3cb56d244c7641170d143cf5d58f2076305355c6006e09a69b

See more details on using hashes here.

File details

Details for the file pygram11-0.5.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pygram11-0.5.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.0

File hashes

Hashes for pygram11-0.5.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d67a14296065e26a9739828ff07400640204b594faea4747e5678a8de8872d83
MD5 2c64d92965ace67f9b9c436d563dd244
BLAKE2b-256 1becf75474fa909c8c6e2cd95bd0998be8c5d47514069a80fef3debba237c201

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygram11-0.5.0-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for pygram11-0.5.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 49586d365bc57f96e3292e1053392467112f927242182aad5b0373281471b69b
MD5 03827285f26cc9ae444211bcbc54b450
BLAKE2b-256 2d6143f76cdc5a4628770b4f4ccde0cda33c7cbfac1c741861ebd95ed58e0203

See more details on using hashes here.

File details

Details for the file pygram11-0.5.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pygram11-0.5.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.0

File hashes

Hashes for pygram11-0.5.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6e42abcb2f2c226b8d60e7245b10b27c5d39884e688cb47bc16f9eadecf839cf
MD5 3a782656d73d034336e670ed5d26dc36
BLAKE2b-256 afac2aa12abf9290f62cd9381770d0c56416d0e8b21b8bc4c508f63e38e20efd

See more details on using hashes here.

File details

Details for the file pygram11-0.5.0-cp27-cp27m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pygram11-0.5.0-cp27-cp27m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 2.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for pygram11-0.5.0-cp27-cp27m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 a2180e3d2cb11e9e021bdcd62398e3678f88dadf555fe77b8ab0d496f16634c3
MD5 b13f160151d17b50577698bcd78742b4
BLAKE2b-256 89754fd80e1603b36b555d37eb4db7a234e4bacd54646b9a60682d24c8c1aabd

See more details on using hashes here.

File details

Details for the file pygram11-0.5.0-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pygram11-0.5.0-cp27-cp27m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 2.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.0

File hashes

Hashes for pygram11-0.5.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 18b6e56e49a8704d24ce7bf0f1be162b304737433a34034f593495984e006358
MD5 9ce76a8b09b4754e5114711a4fad8777
BLAKE2b-256 d07884f5f640e9cc1bed445979ec8a97f23a131efb13c8449aba32f12c292adf

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