Hist classes and utilities
Project description
Hist
Hist is a analyst friendly front-end for boost-histogram, designed for Python 3.7+ (3.6 users get version 2.3). See what's new.
Installation
You can install this library from PyPI with pip:
python3 -m pip install "hist[plot]"
If you do not need the plotting features, you can skip the [plot] extra.
Features
Hist currently provides everything boost-histogram provides, and the following enhancements:
-
Hist augments axes with names:
name=is a unique label describing each axislabel=is an optional string that is used in plotting (defaults tonameif not provided)- Indexing, projection, and more support named axes
- Experimental
NamedHistis aHistthat disables most forms of positional access
-
The
Histclass augmentsbh.Histogramwith reduced typing construction:- Optional import-free construction system
flow=Falseis a fast way to turn off flow for the axes on construction- Storages can be given by string
storage=can be omitteddata=can initialize a histogram with existing dataHist.from_columnscan be used to initialize with a DataFrame or dict
-
Hist implements UHI+; an extension to the UHI (Unified Histogram Indexing) system designed for import-free interactivity:
- Uses
jsuffix to switch to data coordinates in access or slices - Uses
jsuffix on slices to rebin - Strings can be used directly to index into string category axes
- Uses
-
Quick plotting routines encourage exploration:
.plot()provides 1D and 2D plots (or useplot1d(),plot2d()).plot2d_full()shows 1D projects around a 2D plot.plot_ratio(...)make a ratio plot between the histogram and another histogram or callable.plot_pull(...)performs a pull plot.plot_pie()makes a pie plot.show()provides a nice str printout using Histoprint
-
Extended Histogram features:
.density()computes the density as an array.profile(remove_ax)can convert a ND COUNT histogram into a (N-1)D MEAN histogram
-
New modules
intervalssupports frequentist coverage intervals
-
Notebook ready: Hist has gorgeous in-notebook representation.
- No dependencies required
Usage
from hist import Hist
# Quick construction, no other imports needed:
h = (
Hist.new
.Reg(10, 0 ,1, name="x", label="x-axis")
.Var(range(10), name="y", label="y-axis")
.Int64()
)
# Filling by names is allowed:
h.fill(y=[1, 4, 6], x=[3, 5, 2])
# Names can be used to manipulate the histogram:
h.project("x")
h[{"y": 0.5j + 3, "x": 5j}]
# You can access data coordinates or rebin with a `j` suffix:
h[.3j:, ::2j] # x from .3 to the end, y is rebinned by 2
# Elegant plotting functions:
h.plot()
h.plot2d_full()
h.plot_pull(Callable)
Development
From a git checkout, run:
python -m pip install -e .[dev]
See CONTRIBUTING.md for information on setting up a development environment.
Contributors
We would like to acknowledge the contributors that made this project possible (emoji key):
Henry Schreiner 🚧 💻 📖 |
Nino Lau 🚧 💻 📖 |
Chris Burr 💻 |
Nick Amin 💻 |
Eduardo Rodrigues 💻 |
Andrzej Novak 💻 |
Matthew Feickert 💻 |
This project follows the all-contributors specification.
Talks
Acknowledgements
This library was primarily developed by Henry Schreiner and Nino Lau.
Support for this work was provided by the National Science Foundation cooperative agreement OAC-1836650 (IRIS-HEP) and OAC-1450377 (DIANA/HEP). Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the National Science Foundation.
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hist-2.3.0.tar.gz.
File metadata
- Download URL: hist-2.3.0.tar.gz
- Upload date:
- Size: 194.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3be183cb7e36247e56bbecaa278ee70e7c81d6f984c0fd01e26d367866f7f66d
|
|
| MD5 |
ebcae90efefbdcfb1facbe96a6ce471a
|
|
| BLAKE2b-256 |
b7879af6ff51ed4db79764c9ab86308a33011b7be6a837ea8c2e56c4eea9fa85
|
File details
Details for the file hist-2.3.0-py3-none-any.whl.
File metadata
- Download URL: hist-2.3.0-py3-none-any.whl
- Upload date:
- Size: 30.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
137ebac13210c9e3da16e2d76615199c9864daaa5f30fd5f046099868d9cd21f
|
|
| MD5 |
d26246d7790aad226d9e64a0bcdbadcc
|
|
| BLAKE2b-256 |
25ffa2c633f5caa2282501e390ddac0191b87d90779ef97416ae7fc39335f8b2
|