Hypergrid
N-dimensional histogram library for multivariate data.
Hypergrid bins arbitrary-dimensional data into a grid, then lets you update it incrementally, reproject it onto new edges, compare two grids statistically, and visualize the distribution — including UMAP projections and temporal drift.
Installation
# pip
pip install pyHypergrid
# uv
uv add pyHypergrid
Optional extras:
# pip — with pandas (describe()) and/or UMAP support
pip install "pyHypergrid[stats]"
pip install "pyHypergrid[umap]"
pip install "pyHypergrid[stats,umap]"
# uv
uv add "pyHypergrid[stats]"
uv add "pyHypergrid[umap]"
uv add "pyHypergrid[stats,umap]"
Quick start
import numpy as np
from hypergrid import DenseHypergrid, SparseHypergrid, AdaptiveHypergrid, compute_edges
data = np.random.randn(5000, 3)
# Auto-compute edges with Freedman-Diaconis rule
edges = compute_edges(data)
# Dense backend (good for low-dim, mostly populated grids)
grid = DenseHypergrid(edges)
grid.fit(data)
# Sparse backend (good for high-dim or sparse data)
grid = SparseHypergrid(edges)
grid.fit(data)
# Incremental update
grid.update(np.random.randn(500, 3))
Adaptive grid
Automatically rebins when too much data falls outside the current boundaries:
from hypergrid import AdaptiveHypergrid
grid = AdaptiveHypergrid(drift_threshold=0.05, buffer_size=5000)
grid.fit(data_batch_1)
grid.update(data_batch_2) # rebins if >5% overflow
Comparing grids
grid1 = DenseHypergrid(edges); grid1.fit(data1)
grid2 = DenseHypergrid(edges); grid2.fit(data2)
grid1.compare(grid2, method="js") # Jensen-Shannon divergence
grid1.compare(grid2, method="wasserstein") # Earth Mover's Distance
grid1.compare(grid2, method="l1") # Total variation
grid1.compare(grid2, method="kl") # KL divergence
Visualization
grid.plot_all_marginals()
grid.plot_joint(dim_x=0, dim_y=1)
grid.plot_top_bins(k=20)
grid.plot_umap(n_samples=3000)
grid1.compare_umap(grid2)
grid1.compare_marginal(grid2, dim=0)
Temporal tracking
from hypergrid import DenseHypergrid, TemporalHypergrid
base = DenseHypergrid(edges)
tgrid = TemporalHypergrid(base, decay=0.99, snapshot_interval=1000)
for batch in stream:
tgrid.update(batch)
tgrid.plot_evolution(method="js")
tgrid.plot_temporal_umap()
Rebinning
new_edges = compute_edges(new_data)
rebinned = grid.rebin_to(new_edges) # returns dict {index: count}
Architecture
BaseHypergrid (ABC)
└─ BaseTensorHypergrid (+ RebinMixin, ComparisonMixin, EmbeddingMixin, VisualizationMixin)
├─ DenseTensorHypergrid — numpy array backend
├─ SparseTensorHypergrid — bounds-checked sparse dict
├─ StaticHypergrid — pluggable storage backend
└─ AdaptiveHypergrid — auto-rebinning on drift
TemporalHypergrid — wraps any hypergrid, adds decay + snapshots
Storage backends
| Class | Backend | Best for |
|---|---|---|
DenseTensorHypergrid |
numpy array | Low-dim, mostly full grids |
SparseTensorHypergrid |
sparse dict (bounds-checked) | High-dim or sparse data |
StaticHypergrid |
pluggable (default: DictStorage) | Custom backends |
License
MIT
Metadata
Release files for pyHypergrid 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyhypergrid-1.0.0.tar.gz | 1.4 MB | With provenance | Details for pyhypergrid-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyhypergrid-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for pyhypergrid-1.0.0-py3-none-any.whl |
Total release size: 1.4 MB
Release files / pyhypergrid-1.0.0.tar.gz
| Download URL | pyhypergrid-1.0.0.tar.gz |
|---|---|
| Size | 1.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55f5fd312800007387e71fe0e7809a4de1f059f9eb4d3a4dced8b26c7cceed8f
|
|
BLAKE2b-256 checksum How to use checksums |
3a292ef6b35e3861724b9331e0b938b95650efc3bd6c9983dc8ce07ea78b3167
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 6, 2026.
Transparency logRelease files / pyhypergrid-1.0.0-py3-none-any.whl
| Download URL | pyhypergrid-1.0.0-py3-none-any.whl |
|---|---|
| Size | 21.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2837d4753907ed77ffb314759b649a9e6138ad5529197d8e866a1a47b66eae06
|
|
BLAKE2b-256 checksum How to use checksums |
bc59fd31d20c8796ecc377b00886d4fc0e952fca3bd390eb7df48cf173856262
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 6, 2026.
Transparency logSecurity for pyHypergrid 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pyhypergrid-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.