Code Monkey home page Code Monkey logo

hist's Introduction

histogram

Hist

Actions Status Documentation Status Code style: black

PyPI version Conda-Forge PyPI platforms DOI

GitHub Discussion Gitter Scikit-HEP

Hist is a analyst friendly front-end for boost-histogram, designed for Python 3.6+. 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 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
    • Storages can be given by string
    • storage= can be omitted
    • data= can initialize a histogram with existing data
    • Hist.from_columns can 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 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
    • .plot_pie() makes a pie 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")
  .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

๐Ÿ’ป

Eduardo Rodrigues

๐Ÿ’ป

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.

hist's People

Contributors

henryiii avatar lovelybuggies avatar pre-commit-ci[bot] avatar eduardo-rodrigues avatar dependabot[bot] avatar andrzejnovak avatar chrisburr avatar allcontributors[bot] avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.