Fast histogramming in Python built on pybind11 and OpenMP.
Project description
pygram11
Simple and fast histogramming in Python accelerated with OpenMP with help from pybind11.
pygram11
provides functions for very fast histogram calculations
(and the variance in each bin) in one and two dimensions. The API is
very simple; documentation can be found
here (you'll also find some
benchmarks
there).
Installing
From PyPI
Binary wheels are provided for Linux, macOS, and Windows. 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
From Source
You need is a C++14 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 (pygram11 does compile on Apple Silicon devices
with Python version >= 3.9
and libomp
installed from Homebrew).
With those dependencies met, simply run:
git clone https://github.com/douglasdavis/pygram11.git --recurse-submodules
cd pygram11
pip install .
Or let pip handle the cloning procedure:
pip install git+https://github.com/douglasdavis/pygram11.git@main
Tests are run on Python versions >= 3.8
and binary wheels are
provided for those versions.
In Action
A histogram (with fixed bin width) of weighted data in one dimension:
>>> rng = np.random.default_rng(123)
>>> x = rng.standard_normal(10000)
>>> w = rng.uniform(0.8, 1.2, x.shape[0])
>>> 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 = rng.standard_normal(1000000)
>>> h, __ = pygram11.histogram(x, bins=20, range=(-3, 3), flow=True)
where we've used __
to catch the None
returned when weights are
absent. A histogram in two dimensions with variable width bins:
>>> x = rng.standard_normal(1000)
>>> y = rng.standard_normal(1000)
>>> xbins = [-2.0, -1.0, -0.5, 1.5, 2.0, 3.1]
>>> ybins = [-3.0, -1.5, -0.1, 0.8, 2.0, 2.8]
>>> h, err = pygram11.histogram2d(x, y, bins=[xbins, ybins])
Manually controlling OpenMP acceleration with context managers:
>>> with pygram11.omp_disabled(): # disable all thresholds.
... result, _ = pygram11.histogram(x, bins=10, range=(-3, 3))
...
>>> with pygram11.omp_forced(key="thresholds.var1d"): # force a single threshold.
... result, _ = pygram11.histogram(x, bins=[-3, -2, 0, 2, 3])
...
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):
>>> N = 10000
>>> weights = pd.DataFrame({"weight_a": np.abs(rng.standard_normal(N)),
... "weight_b": rng.uniform(0.5, 0.8, N),
... "weight_c": rng.uniform(0.0, 1.0, N)})
>>> data = rng.standard_normal(N)
>>> 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
- boost-histogram provides Pythonic object oriented histograms.
- Simple and fast histogramming in Python using the NumPy C API: fast-histogram (no variance or overflow support).
- To calculate histograms in Python on a GPU, see cupy.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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file pygram11-0.13.2.tar.gz
.
File metadata
- Download URL: pygram11-0.13.2.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fe0e9c6311c3b6143c1a6e264bdf568d135f0aa92bd6b818ec76407b27fb54c |
|
MD5 | 6d24d8629babe45c012352693657fba1 |
|
BLAKE2b-256 | d63ffaaa8c1dfa99bc6ba6e6cc877a571ad97e557cd60405f09da9fe4926ba09 |
File details
Details for the file pygram11-0.13.2-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 451.4 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a21b2ccf8e43d6d49f008d2899ece7faf4cb2533c147d7d40a0c30773f67835c |
|
MD5 | c0ebc1eed09a2df00645deedffdd3936 |
|
BLAKE2b-256 | ff511a8f1c4139f34a6277a1e63ce975a70d15719d6ab2f5f06cd3a9d5f77832 |
File details
Details for the file pygram11-0.13.2-cp311-cp311-win32.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp311-cp311-win32.whl
- Upload date:
- Size: 314.6 kB
- Tags: CPython 3.11, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9004b0c64bfc67973119a0336d244ccd22edfcc2f5886e846a258a68e305bfbe |
|
MD5 | bc30eb87f5ecb9f5069a7b78f5577195 |
|
BLAKE2b-256 | 5fbd9764bf933fe987c6b9d43a6f267abc5519487a25705b580c40358c583d0d |
File details
Details for the file pygram11-0.13.2-cp311-cp311-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp311-cp311-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.11, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 242ed9bd72d622579c26b197d9562575fd70b218b9af676cb828834e82387de5 |
|
MD5 | 7b47cead23749f426d5aeffc84bf75b0 |
|
BLAKE2b-256 | 51f32fc7c774026f757e1375c3b93648d11c539ccd21ae6bd59f93b2a114f943 |
File details
Details for the file pygram11-0.13.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 476.2 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a9f46df8b3db448f0d3f776a9c6f7d9ed7cd14395c50731ab882b9aeba227c6 |
|
MD5 | 9fc49ffbd9d290c0b8b7c54ee651b581 |
|
BLAKE2b-256 | 886f7c0c03a3fe809241f83c3c451277e4b8d07c54bd9132400cbdafe4894976 |
File details
Details for the file pygram11-0.13.2-cp311-cp311-macosx_12_0_arm64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp311-cp311-macosx_12_0_arm64.whl
- Upload date:
- Size: 661.2 kB
- Tags: CPython 3.11, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 980434bbeba2f3c3e10f5e6af14d0a27f5899bcbf477807220f91bfcbd722197 |
|
MD5 | 7b81bf98d1b48174512b21401c56888a |
|
BLAKE2b-256 | e69b51ddebec8c9cdcf4d7ff4dfc4f037ff95fa2a8c9181c0b547a455bc27767 |
File details
Details for the file pygram11-0.13.2-cp311-cp311-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 821.9 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dacbe577849e5d69f8535524f141b8e11867032288278fd7876f113e8c4846e6 |
|
MD5 | d712f199981ab883102fce9a659f64bd |
|
BLAKE2b-256 | 00d8cb8415a2a9b3393e9d957d9efd3a9fbbc06b263630d44b4fb36d650ed3a4 |
File details
Details for the file pygram11-0.13.2-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 451.5 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df43c8c8cc907b7e91a4a6b33eb6ab4115f4ff85f466239a2b0a1e1532b7be61 |
|
MD5 | fa69ee8e3a0b8f13997fc3f836807d89 |
|
BLAKE2b-256 | 9e6c50be346ac8d5a2366c9d1e56419f50d7f1918219a194275ac74a19b75782 |
File details
Details for the file pygram11-0.13.2-cp310-cp310-win32.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp310-cp310-win32.whl
- Upload date:
- Size: 314.6 kB
- Tags: CPython 3.10, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52287fa5faac5baca9c6fc369095d127e013653614700f2c553132341e500359 |
|
MD5 | 5a62a66fdfe0229743aad2becbddb07c |
|
BLAKE2b-256 | 36611c720d54fa5f7ddeadabafe944c7de3da98555189fee939e294f50c45394 |
File details
Details for the file pygram11-0.13.2-cp310-cp310-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp310-cp310-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.10, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f905dad9a3d62fffd0f78f483cd5e8d43e89015e123135cf1f3b8aa4aa913754 |
|
MD5 | 864e9455ffa11bbb8b6319c0caf702fd |
|
BLAKE2b-256 | 9da81dd224d59729964272fa85e2c2b12218d9c93172ef9558ad79db29b947ad |
File details
Details for the file pygram11-0.13.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 476.2 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55616e8e01df7dbdfe25f7dd032632ae85836a0adcc73e4c1a54c4deff689774 |
|
MD5 | 09926c0659d7397e2230e0df94b8ee45 |
|
BLAKE2b-256 | 75b9ca35a77ba1ffa477e53b01f5637086e4321599360fe7c78944a17946c9f6 |
File details
Details for the file pygram11-0.13.2-cp310-cp310-macosx_12_0_arm64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp310-cp310-macosx_12_0_arm64.whl
- Upload date:
- Size: 661.2 kB
- Tags: CPython 3.10, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfd8e320c99655b487e1424b131dcdbed25993e5fed098917b94d8b2f84dca42 |
|
MD5 | 7cb897a20ab3618f1e7f0378d940e0a5 |
|
BLAKE2b-256 | e8f9e1cbb2029915669366c500957a3d683b57d10b2e1e350c6a534d638d092a |
File details
Details for the file pygram11-0.13.2-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 821.9 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d1806b1f4d72cf892f88ede8ee99db3465c888b97a0fe228f819c10731699af |
|
MD5 | 13afdecef0cb4b560ef1d836d2a269ba |
|
BLAKE2b-256 | a2a0e2eed2e421cdba9be8d0d913947db6c6fb6d18a7b8ba3114a1cc250b2b54 |
File details
Details for the file pygram11-0.13.2-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 438.4 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac2494cffb2e427cb72f9ba1078279918a1841a8f2954484f75cf77f00c4c2dc |
|
MD5 | 6fd648214794a2237c4bb6888c3f500f |
|
BLAKE2b-256 | 7ecc9f7703b7de155699b83b3c38502aca653622a8c80efb74397be0551b53e0 |
File details
Details for the file pygram11-0.13.2-cp39-cp39-win32.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp39-cp39-win32.whl
- Upload date:
- Size: 316.8 kB
- Tags: CPython 3.9, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4a1bdc5181b384146227be35dc7f4078a73b376d62568dd17f12696a97ad553 |
|
MD5 | 252a2564fa58ca2c929d4ce7adecb39d |
|
BLAKE2b-256 | 1324e36ed0be65a612c7c7eb6e9e3f9f3f9724a7385fb894cb318b349789cbed |
File details
Details for the file pygram11-0.13.2-cp39-cp39-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp39-cp39-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.9, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16e5f2fe80c92747a153e1f1aaf69b1b08decdcde693ee3408c6706a7ea183d8 |
|
MD5 | 0e3c15066d2073dd68bd4135db6ac244 |
|
BLAKE2b-256 | 015a4b1a32c5068bae36b15a1ba55c1aeb53e3107d940beb752856c6237e88e8 |
File details
Details for the file pygram11-0.13.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 469.6 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eec4df4aaeb71beaa6fb8c3862a7321017aebe207c3bba887cf535882dec83f5 |
|
MD5 | 6595e34117f644c77735718751ef32b1 |
|
BLAKE2b-256 | e70bd7aa51e62229151d023f92fe20ecfb1167f8bc33e8b56b424b853428bc63 |
File details
Details for the file pygram11-0.13.2-cp39-cp39-macosx_12_0_arm64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp39-cp39-macosx_12_0_arm64.whl
- Upload date:
- Size: 661.3 kB
- Tags: CPython 3.9, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 737ce82836910e7b791943854aed84256d10891584ac0ba07dde9458b2e8c4a4 |
|
MD5 | c9b3b58090aec1644be4e36db148c532 |
|
BLAKE2b-256 | 6beb89fb6a46564491702d3cf43da844a7888c2865d433c804c9cd4ca673db91 |
File details
Details for the file pygram11-0.13.2-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 822.1 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f89a881e6350ce15346d26c24823f6dce9ea4d868b2f6aa9262b352041becd9c |
|
MD5 | bd99142f0da7df0e25c76c7ec3ec671d |
|
BLAKE2b-256 | 18219eed39455d2f6626b54d2b1a88f50fca3c35287ef876e8716d2c0d7bbb13 |
File details
Details for the file pygram11-0.13.2-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 451.3 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10f26bfa00e0e1b79f4b967e6b2d2ff5a4486cc507c4567f6070fc5325540497 |
|
MD5 | 5e250e6fedb1671212c08a353dcb5590 |
|
BLAKE2b-256 | bbdf7d21b9f5c9ce1a9292ea5774edea08fed54f8ab95e23f8ae3154ac4a4a28 |
File details
Details for the file pygram11-0.13.2-cp38-cp38-win32.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp38-cp38-win32.whl
- Upload date:
- Size: 314.5 kB
- Tags: CPython 3.8, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 924bac140c30ea25b473c29200ba825f49a33b60f212d39bd67d94b0b2f02617 |
|
MD5 | d8d100551e4e8db782b3dc102b680eee |
|
BLAKE2b-256 | ed6b31fc24eb7b540abf02daa33b11e41039bb5226afb412bcdbe9318791247d |
File details
Details for the file pygram11-0.13.2-cp38-cp38-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp38-cp38-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.8, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff8d737bb9875139035a223f2afc6a310293c2942c303ae31c6eae00c5f86142 |
|
MD5 | 3354ec9a30edbea51e4054f1be35b0b1 |
|
BLAKE2b-256 | 8ce1e8190714f48000f06c13b12164f405bdc2773318984027a95579ea5b509c |
File details
Details for the file pygram11-0.13.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 477.4 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28c34c2763515f7194261f1ffdc0388af38b7ee6aed985c0500abf9b62e58c9f |
|
MD5 | 7117ff73fd982c144356bff645fbfc82 |
|
BLAKE2b-256 | 7206533178b3938ddb9622a25ad89e525e699fac91785105a49613e821a8b812 |
File details
Details for the file pygram11-0.13.2-cp38-cp38-macosx_12_0_arm64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp38-cp38-macosx_12_0_arm64.whl
- Upload date:
- Size: 661.2 kB
- Tags: CPython 3.8, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f74cbd1d8f3143aad290c30cb4b35179b585f3c27b4608b1593c8264df0b7c7 |
|
MD5 | 2af5097504966169d2889a34cc9bf109 |
|
BLAKE2b-256 | 923a267c83f0f2ef08a99dcb608c73e3d0d6c6c1a355c51695ae5494f416f0ab |
File details
Details for the file pygram11-0.13.2-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pygram11-0.13.2-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 821.9 kB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f71509013127b165d27bc9ff86e5d4568e08d7e77aeee25a32d4b3948fac7486 |
|
MD5 | f4f4585593c9dfd226af133321499e11 |
|
BLAKE2b-256 | cc96c62f372d91f63602f46cfe0e4a3e666195ca4e4120e6c82462b5b1d0a1a9 |