{"id":15048031,"url":"https://github.com/douglasdavis/pygram11","last_synced_at":"2025-07-28T17:04:49.860Z","repository":{"id":53117560,"uuid":"168767581","full_name":"douglasdavis/pygram11","owner":"douglasdavis","description":"Simple and fast histogramming in Python accelerated with OpenMP.","archived":false,"fork":false,"pushed_at":"2024-03-12T00:32:31.000Z","size":1340,"stargazers_count":29,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-18T18:39:21.945Z","etag":null,"topics":["calculating-histograms","conda-forge","cpp14","histogram","histograms","macos","numpy","openmp","pybind11","pypi","python","python3","weights"],"latest_commit_sha":null,"homepage":"https://pygram11.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/douglasdavis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-01T22:19:44.000Z","updated_at":"2024-10-30T02:44:28.000Z","dependencies_parsed_at":"2024-03-12T01:46:37.405Z","dependency_job_id":null,"html_url":"https://github.com/douglasdavis/pygram11","commit_stats":{"total_commits":601,"total_committers":3,"mean_commits":"200.33333333333334","dds":0.06821963394342767,"last_synced_commit":"b10491ba527c5430f94ff2eb09e0f92a32c9c832"},"previous_names":[],"tags_count":67,"template":false,"template_full_name":null,"purl":"pkg:github/douglasdavis/pygram11","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/douglasdavis%2Fpygram11","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/douglasdavis%2Fpygram11/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/douglasdavis%2Fpygram11/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/douglasdavis%2Fpygram11/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/douglasdavis","download_url":"https://codeload.github.com/douglasdavis/pygram11/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/douglasdavis%2Fpygram11/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267552094,"owners_count":24105998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["calculating-histograms","conda-forge","cpp14","histogram","histograms","macos","numpy","openmp","pybind11","pypi","python","python3","weights"],"created_at":"2024-09-24T21:07:11.221Z","updated_at":"2025-07-28T17:04:49.810Z","avatar_url":"https://github.com/douglasdavis.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pygram11\n\n[![Documentation Status](https://readthedocs.org/projects/pygram11/badge/?version=latest)](https://pygram11.readthedocs.io/en/latest/?badge=latest)\n[![Actions Status](https://github.com/douglasdavis/pygram11/workflows/Tests/badge.svg)](https://github.com/douglasdavis/pygram11/actions)\n[![PyPI version](https://img.shields.io/pypi/v/pygram11.svg?colorB=486b87\u0026style=flat)](https://pypi.org/project/pygram11/)\n[![Conda Forge](https://img.shields.io/conda/vn/conda-forge/pygram11.svg?colorB=486b87\u0026style=flat)](https://anaconda.org/conda-forge/pygram11)\n[![Python Version](https://img.shields.io/pypi/pyversions/pygram11)](https://pypi.org/project/pygram11/)\n\nSimple and fast histogramming in Python accelerated with\n[OpenMP](https://www.openmp.org/) with help from\n[pybind11](https://github.com/pybind/pybind11).\n\n`pygram11` provides functions for very fast histogram calculations\n(and the variance in each bin) in one and two dimensions. The API is\nvery simple; documentation can be [found\nhere](https://pygram11.readthedocs.io/) (you'll also find [some\nbenchmarks](https://pygram11.readthedocs.io/en/stable/bench.html)\nthere).\n\n## Installing\n\n### From PyPI\n\nBinary wheels are provided for Linux, macOS, and Windows. They can be\ninstalled from [PyPI](https://pypi.org/project/pygram11/) via pip:\n\n```\npip install pygram11\n```\n\n### From conda-forge\n\nFor installation via the `conda` package manager [pygram11 is part of\nconda-forge](https://anaconda.org/conda-forge/pygram11).\n\n```none\nconda install pygram11 -c conda-forge\n```\n\n### From Source\n\nYou need is a C++14 compiler and OpenMP. If you are using a relatively\nmodern GCC release on Linux then you probably don't have to worry\nabout the OpenMP dependency. If you are on macOS, you can install\n`libomp` from Homebrew (pygram11 does compile on Apple Silicon devices\nwith Python version `\u003e= 3.9` and `libomp` installed from Homebrew).\nWith those dependencies met, simply run:\n\n```none\ngit clone https://github.com/douglasdavis/pygram11.git --recurse-submodules\ncd pygram11\npip install .\n```\n\nOr let pip handle the cloning procedure:\n\n```none\npip install git+https://github.com/douglasdavis/pygram11.git@main\n```\n\nTests are run on Python versions `\u003e= 3.8` and binary wheels are\nprovided for those versions.\n\n## In Action\n\nA histogram (with fixed bin width) of weighted data in one dimension:\n\n```python\n\u003e\u003e\u003e rng = np.random.default_rng(123)\n\u003e\u003e\u003e x = rng.standard_normal(10000)\n\u003e\u003e\u003e w = rng.uniform(0.8, 1.2, x.shape[0])\n\u003e\u003e\u003e h, err = pygram11.histogram(x, bins=40, range=(-4, 4), weights=w)\n```\n\nA histogram with fixed bin width which saves the under and overflow in\nthe first and last bins:\n\n```python\n\u003e\u003e\u003e x = rng.standard_normal(1000000)\n\u003e\u003e\u003e h, __ = pygram11.histogram(x, bins=20, range=(-3, 3), flow=True)\n```\n\nwhere we've used `__` to catch the `None` returned when weights are\nabsent. A histogram in two dimensions with variable width bins:\n\n```python\n\u003e\u003e\u003e x = rng.standard_normal(1000)\n\u003e\u003e\u003e y = rng.standard_normal(1000)\n\u003e\u003e\u003e xbins = [-2.0, -1.0, -0.5, 1.5, 2.0, 3.1]\n\u003e\u003e\u003e ybins = [-3.0, -1.5, -0.1, 0.8, 2.0, 2.8]\n\u003e\u003e\u003e h, err = pygram11.histogram2d(x, y, bins=[xbins, ybins])\n```\n\nManually controlling OpenMP acceleration with context managers:\n\n```python\n\u003e\u003e\u003e with pygram11.omp_disabled():  # disable all thresholds.\n...     result, _ = pygram11.histogram(x, bins=10, range=(-3, 3))\n...\n\u003e\u003e\u003e with pygram11.omp_forced(key=\"thresholds.var1d\"):  # force a single threshold.\n...     result, _ = pygram11.histogram(x, bins=[-3, -2, 0, 2, 3])\n...\n```\n\nHistogramming multiple weight variations for the same data, then\nputting the result in a DataFrame (the input pandas DataFrame will be\ninterpreted as a NumPy array):\n\n```python\n\u003e\u003e\u003e N = 10000\n\u003e\u003e\u003e weights = pd.DataFrame({\"weight_a\": np.abs(rng.standard_normal(N)),\n...                         \"weight_b\": rng.uniform(0.5, 0.8, N),\n...                         \"weight_c\": rng.uniform(0.0, 1.0, N)})\n\u003e\u003e\u003e data = rng.standard_normal(N)\n\u003e\u003e\u003e count, err = pygram11.histogram(data, bins=20, range=(-3, 3), weights=weights, flow=True)\n\u003e\u003e\u003e count_df = pd.DataFrame(count, columns=weights.columns)\n\u003e\u003e\u003e err_df = pd.DataFrame(err, columns=weights.columns)\n```\n\nI also wrote a [blog\npost](https://ddavis.io/posts/introducing-pygram11/) with some simple\nexamples.\n\n## Other Libraries\n\n- [boost-histogram](https://github.com/scikit-hep/boost-histogram)\n  provides Pythonic object oriented histograms.\n- Simple and fast histogramming in Python using the NumPy C API:\n  [fast-histogram](https://github.com/astrofrog/fast-histogram) (no\n  variance or overflow support).\n- To calculate histograms in Python on a GPU, see\n  [cupy.histogram](https://docs.cupy.dev/en/stable/reference/generated/cupy.histogram.html).\n\n---\n\nIf there is something you'd like to see in pygram11, please open an\nissue or pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdouglasdavis%2Fpygram11","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdouglasdavis%2Fpygram11","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdouglasdavis%2Fpygram11/lists"}