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

Hist is a analyst friendly front-end for boost-histogram.

Installation

You can install this library from PyPI with pip:

python -m pip install hist

Usage

import hist

# You can create a histogram like this.
h = (
  hist.Hist()
  .Reg(10, 0 ,1, name="x", title="x-axis")
  .Variable(range(10), name="y", title="y-axis")
  .Int64()
)

# Filling by names is allowed in hist.
hist.fill(y=[1, 4, 6], x=[3, 5, 2])

# New ways to manipulate the histogram.
h.project("x")
h[{"y": 1j + 3, "x": 5j}]
...

# Elegant plotting functions.
h.plot()
h.plot2d_full()
h.plot_pull(Callable)
...

Features

  • Hist augments metadata by adding names to axes; these are highly recommend and will help you track axes. There is also a special NamedHist, which will enforce all hist axes have names, and all axes will require named access.

    • name= is a unique label describing each axis
    • title= is an optional string that is used in plotting (defaults to name if not provided)
    • Indexing, projection, and more support named axes.
  • The Hist class augments the bh.Histogram class with the following shortcuts, designed for interactive exploration without extensive imports:

    • Optional import-free construction system
    • Quick import-free data-coordinates and rebin syntax (use a j suffix for numbers, or strings directly in indexing expressions)
  • 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

Development

See CONTRIBUTING.md for information on setting up a development environment.

python -m pip install hist

Usage

import hist

# You can create a histogram like this.
h = (
  hist.Hist()
  .Reg(10, 0 ,1, name="x", title="x-axis")
  .Variable(range(10), name="y", title="y-axis")
  .Int64()
)

# Filling by names is allowed in hist.
hist.fill(y=[1, 4, 6], x=[3, 5, 2])

# New ways to manipulate the histogram.
h.project("x")
h[{"y": 1j + 3, "x": 5j}]
...

# Elegant plotting functions.
h.plot()
h.plot2d_full()
h.plot_pull(Callable)
...

Features

  • Hist augments metadata by adding names to axes; these are highly recommend and will help you track axes. There is also a special NamedHist, which will enforce all hist axes have names, and all axes will require named access.

    • name= is a unique label describing each axis
    • title= is an optional string that is used in plotting (defaults to name if not provided)
    • Indexing, projection, and more support named axes.
  • The Hist class augments the bh.Histogram class with the following shortcuts, designed for interactive exploration without extensive imports:

    • Optional import-free construction system
    • Quick import-free data-coordinates and rebin syntax (use a j suffix for numbers, or strings directly in indexing expressions)
  • 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

Development

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.0a5.tar.gz (280.8 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: hist-2.0.0a5.tar.gz
  • Upload date:
  • Size: 280.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.4

File hashes

Hashes for hist-2.0.0a5.tar.gz
Algorithm Hash digest
SHA256 9eabcc726c85613bae85feadfd745028ada9c62b2900b0561cee8343341c0b93
MD5 ded3c19a7340c0c682eedff50fcb0297
BLAKE2b-256 408f642bfea276444b5823f83135b5f84eeb22c8944e0c5cad8dc2f6e579d367

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hist-2.0.0a5-py3-none-any.whl
  • Upload date:
  • Size: 15.8 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/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.4

File hashes

Hashes for hist-2.0.0a5-py3-none-any.whl
Algorithm Hash digest
SHA256 caa3e11ee3c007e8f82b8541e06c4d91742e4c541292f87515006fec1643a7b8
MD5 ba94fffa8095acb92f9bbf7e6ad715e8
BLAKE2b-256 c5f9cef353e5cd1c865635a92e4f920117a62eb9a20c4331490f9dccd8c1dbb7

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