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 (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.

Installing

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 setup.py 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 https://github.com/drdavis/pygram11.git
$ 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])

Other Libraries

  • There is an effort to develop an object oriented histogramming library for python called boost-histogram
  • Simple and fast histogramming in Python using the NumPy C API: fast-histogram

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

This version

0.3.0

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.3.0.tar.gz (13.8 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: pygram11-0.3.0.tar.gz
  • Upload date:
  • Size: 13.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.28.1 CPython/3.7.3

File hashes

Hashes for pygram11-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6783c9c2c55a7ef9b6e41b50c42cf20559ec7f8423b6659217f186deceb17a9f
MD5 6c477937bd62349fe64858dff508c798
BLAKE2b-256 e3269c55dbb8c6d646876bc645a87e8c15d5a7eeb4de1be2713c8a669bbefbad

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