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 which provides OpenMP acceleration, pygram11 is part of conda-forge.

conda install pygram11 -c conda-forge

From PyPI

Note: When using PyPI (or source), pybind11 must be installed explicitly before pygram11 (because setup.py uses pybind11 to determine include directories; not an issue if using the conda-forge build). For ensuring OpenMP acceleration is available in your installation read this section of the documentation.

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

From Source

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

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.0a1.tar.gz (144.6 kB view details)

Uploaded Source

Built Distributions

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

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

pygram11-0.5.0a1-cp37-cp37m-macosx_10_9_x86_64.whl (109.3 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

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

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

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

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

File details

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

File metadata

  • Download URL: pygram11-0.5.0a1.tar.gz
  • Upload date:
  • Size: 144.6 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.0a1.tar.gz
Algorithm Hash digest
SHA256 2a681db5bf63bc5c60203feee0addf16b8b57e57e6d6d176c03efd06fb9f266d
MD5 24e764d0dbe236be3e70e9a97639e911
BLAKE2b-256 6a88e003966f2daf231df24ab10abea57e1f22f4c77f72a7e2d85c34e37a5ef9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygram11-0.5.0a1-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.4 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.0a1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 03b65743e677d44953afd2fc126e8bc8a609d86a8c745f56f125a77b647dc327
MD5 06df0d937d9049663d35323470c4df7f
BLAKE2b-256 ca17a38e99b2dda94cb0348d86bd4df954381dba293862885f7db36e987046fc

See more details on using hashes here.

File details

Details for the file pygram11-0.5.0a1-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: pygram11-0.5.0a1-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 109.3 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for pygram11-0.5.0a1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2ba061c19e1c49f08de355b6603a02fbe11273d9567bda1eda48d7730d20b86c
MD5 48757b1e72cee5613a026e2c4fa38245
BLAKE2b-256 b46d5882bab7abaff270dbb8f2290e05db311037737cbeaf3b5eaebe91851f3d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygram11-0.5.0a1-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.4 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.0a1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 5cedb3c1319f91605f5cca52018fd396d266207a6327fd423836ad239155f343
MD5 b6c26d49aac6b8d80a4b6944a2b431f7
BLAKE2b-256 c4ca7f1167a57d55816d70d2483f2481e120fddac836d019759bb11556efd267

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygram11-0.5.0a1-cp27-cp27m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.4 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.0a1-cp27-cp27m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 e9a8ee957613ad4b61dc5fa8077b3dd6938470438b61fe862f1088c51e375351
MD5 c984b5b66876312ee3fd689de399bd26
BLAKE2b-256 1774c3e903337e33d23df58b9375c775a853ca088c4ae5d396b1d91287c9167d

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