https://github.com/douglasdavis/pygram11

Simple and fast histogramming in Python accelerated with OpenMP.

https://github.com/douglasdavis/pygram11

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

calculating-histograms conda-forge cpp14 histogram histograms macos numpy openmp pybind11 pypi python python3 weights
Last synced: 5 months ago · JSON representation

Repository

Simple and fast histogramming in Python accelerated with OpenMP.

Basic Info
Statistics
  • Stars: 30
  • Watchers: 2
  • Forks: 2
  • Open Issues: 0
  • Releases: 48
Topics
calculating-histograms conda-forge cpp14 histogram histograms macos numpy openmp pybind11 pypi python python3 weights
Created about 7 years ago · Last pushed 6 months ago
Metadata Files
Readme License

README.md

pygram11

Documentation Status Actions Status PyPI version Conda Forge

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

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

All Time
  • Total Commits: 602
  • Total Committers: 2
  • Avg Commits per committer: 301.0
  • Development Distribution Score (DDS): 0.01
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Doug Davis d****s@d****o 596
Douglas Davis d****s@c****h 6
Committer Domains (Top 20 + Academic)

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
enhancement (2)

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.

  • Versions: 69
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 3,246 Last month
Rankings
Dependent packages count: 4.7%
Average: 13.5%
Downloads: 14.1%
Dependent repos count: 21.7%
Maintainers (1)
Last synced: 5 months ago
conda-forge.org: pygram11

Simple and fast histogramming with a NumPy like API, built on pybind11 and accelerated with OpenMP.

  • Versions: 30
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 34.0%
Stargazers count: 42.3%
Average: 45.4%
Dependent packages count: 51.2%
Forks count: 54.2%
Last synced: 5 months ago

Dependencies

docs/requirements.txt pypi
  • furo >=2021.4.11b34
  • ipython >=7.20
  • sphinx >=3.4.0
.github/workflows/build.yml actions
  • 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
.github/workflows/ci.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v2 composite
pyproject.toml pypi
  • numpy *