Bin

class coffea.hist.Bin(name, label, n_or_arr, lo=None, hi=None)[source]

Bases: DenseAxis

A binned axis with name, label, and binning.

Parameters:
  • name (str) – is used as a keyword in histogram filling, immutable

  • label (str) – describes the meaning of the axis, can be changed

  • n_or_arr (int or list or numpy.ndarray) – Integer number of bins, if uniform binning. Otherwise, a list or numpy 1D array of bin boundaries.

  • lo (float, optional) – lower boundary of bin range, if uniform binning

  • hi (float, optional) – upper boundary of bin range, if uniform binning

This axis will generate frequencies for n+3 bins, special bin indices: 0 = underflow, n+1 = overflow, n+2 = nanflow Bin boundaries are [lo, hi)

Attributes Summary

size

Number of bins, including overflow (i.e. n + 3).

Methods Summary

centers([overflow])

Bin centers

edges([overflow])

Bin boundaries

identifiers([overflow])

List of Interval identifiers

index(identifier)

Index of a identifer or label

reduced(islice)

Return a new axis with reduced binning

Attributes Documentation

size

Number of bins, including overflow (i.e. n + 3)

Methods Documentation

centers(overflow='none')[source]

Bin centers

Parameters:

overflow (str) – Create overflow and/or underflow bins by adding a bin of same width to each end. See Hist.sum description for the allowed values.

edges(overflow='none')[source]

Bin boundaries

Parameters:

overflow (str) – Create overflow and/or underflow bins by adding a bin of same width to each end. See Hist.sum description for the allowed values.

identifiers(overflow='none')[source]

List of Interval identifiers

index(identifier)[source]

Index of a identifer or label

Parameters:

identifier (float or Interval or numpy.ndarray) – The identifier(s) to lookup. Supports vectorized calls when a numpy 1D array of numbers is passed.

Returns an integer corresponding to the index in the axis where the histogram would be filled. The integer range includes flow bins: 0 = underflow, n+1 = overflow, n+2 = nanflow

reduced(islice)[source]

Return a new axis with reduced binning

The new binning corresponds to the slice made on this axis. Overflow will be taken care of by Hist.__getitem__

Parameters:

islice (slice) – islice.start and islice.stop should be None or within [1, ax.size() - 1] This slice is usually as returned from Bin._ireduce