Skip to main content

Hist classes and utilities

Project description

Hist

Github Actions badge Join the chat at https://gitter.im/Scikit-HEP/hist Code style: black Scikit-HEP

Hist is a analyst friendly front-end for boost-histogram, designed for Python 3.6+.

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 axis.
    • label= is an optional string that is used in plotting (defaults to name if not provided).
    • Indexing, projection, and more support named axes.
    • Experimental NamedHist is a Hist that disables most forms of positional access.
  • The Hist class augments bh.Histogram with reduced typing construction:

    • Optional import-free construction system
    • flow=False is a fast way to turn off flow
  • Hist implements UHI+; an extension to the UHI system designed for import-free interactivity:

    • Uses j suffix to switch to data coordinates in access or slices
    • Uses j suffix on slices to rebin
    • Strings can be used directly to index into string category axes
  • Quick plotting routines encourage exploration:

    • .plot() provides 1D and 2D plots
    • .plot2d_full() shows 1D projects around a 2D plot
    • .plot_pull(...) performs a pull plot
  • 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")
  .Variable(range(10), name="y", label="y-axis")
  .Int64()
)

# Filling by names is allowed:
hist.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

🚧 💻📖

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hist-2.0.0.tar.gz (559.7 kB view details)

Uploaded Source

Built Distribution

hist-2.0.0-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file hist-2.0.0.tar.gz.

File metadata

  • Download URL: hist-2.0.0.tar.gz
  • Upload date:
  • Size: 559.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6

File hashes

Hashes for hist-2.0.0.tar.gz
Algorithm Hash digest
SHA256 48edff8f498ea7c5c6d8057c6f001a2ce394acd0923b921c56b76fb732e11df3
MD5 3289183b82090960245d8a21d5ad3e11
BLAKE2b-256 4b3e4046926340450139bc0f67e62ab7e5c9d534a67a77ebc5111a8b0c33e38e

See more details on using hashes here.

File details

Details for the file hist-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: hist-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6

File hashes

Hashes for hist-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78f385fd555fee718690727f55f82c9e21de2422ea7075a5c015cdf9a02df855
MD5 d3122fa333dd4ab154c2078d06050fc0
BLAKE2b-256 c311cc22d1d2eca4ef2da851ccbf0e5b49b11ec0a11f4f8c7c1e31b4245b072d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page