https://github.com/douglasdavis/pygram11
Simple and fast histogramming in Python accelerated with OpenMP.
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 2 committers (50.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.0%) to scientific vocabulary
Keywords
Repository
Simple and fast histogramming in Python accelerated with OpenMP.
Basic Info
- Host: GitHub
- Owner: douglasdavis
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://pygram11.readthedocs.io
- Size: 1.28 MB
Statistics
- Stars: 30
- Watchers: 2
- Forks: 2
- Open Issues: 0
- Releases: 48
Topics
Metadata Files
README.md
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.
none
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.
none
git clone https://github.com/douglasdavis/pygram11.git --recurse-submodules
cd pygram11
pip install .
Or let pip handle the cloning procedure:
none
pip install git+https://github.com/douglasdavis/pygram11.git@main
Tests are run on Python versions >= 3.11 and binary wheels are
provided for those versions.
In Action
A histogram (with fixed bin width) of weighted data in one dimension:
```python
rng = np.random.defaultrng(123) x = rng.standardnormal(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:
```python
x = rng.standardnormal(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:
```python
x = rng.standardnormal(1000) y = rng.standardnormal(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:
```python
with pygram11.ompdisabled(): # disable all thresholds. ... result, _ = pygram11.histogram(x, bins=10, range=(-3, 3)) ... with pygram11.ompforced(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):
```python
N = 10000 weights = pd.DataFrame({"weighta": np.abs(rng.standardnormal(N)), ... "weightb": rng.uniform(0.5, 0.8, N), ... "weightc": rng.uniform(0.0, 1.0, N)}) data = rng.standardnormal(N) count, err = pygram11.histogram(data, bins=20, range=(-3, 3), weights=weights, flow=True) countdf = 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.
Owner
- Name: Doug Davis
- Login: douglasdavis
- Kind: user
- Location: Austin, TX
- Website: https://ddavis.io
- Repositories: 76
- Profile: https://github.com/douglasdavis
GitHub Events
Total
- Release event: 1
- Push event: 12
- Create event: 3
Last Year
- Release event: 1
- Push event: 12
- Create event: 3
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Doug Davis | d****s@d****o | 596 |
| Douglas Davis | d****s@c****h | 6 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 2
- Total pull requests: 16
- Average time to close issues: about 1 month
- Average time to close pull requests: 3 days
- Total issue authors: 2
- Total pull request authors: 1
- Average comments per issue: 4.0
- Average comments per pull request: 0.0
- Merged pull requests: 14
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- Huararanga (1)
- tim-hilt (1)
Pull Request Authors
- douglasdavis (16)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 3,246 last-month
-
Total dependent packages: 1
(may contain duplicates) -
Total dependent repositories: 1
(may contain duplicates) - Total versions: 99
- Total maintainers: 1
pypi.org: pygram11
Fast histogramming in Python built on pybind11 and OpenMP.
- Documentation: https://pygram11.readthedocs.io/
- License: MIT License
-
Latest release: 0.13.3
published 6 months ago
Rankings
Maintainers (1)
conda-forge.org: pygram11
Simple and fast histogramming with a NumPy like API, built on pybind11 and accelerated with OpenMP.
- Homepage: http://github.com/douglasdavis/pygram11
- License: MIT
-
Latest release: 0.13.1
published over 3 years ago
Rankings
Dependencies
- furo >=2021.4.11b34
- ipython >=7.20
- sphinx >=3.4.0
- actions/checkout v3 composite
- actions/setup-python v2 composite
- actions/upload-artifact v3 composite
- actions/upload-artifact v2 composite
- pypa/cibuildwheel v2.9.0 composite
- actions/checkout v3 composite
- actions/setup-python v2 composite
- numpy *