cuda_histogram.axis package

class cuda_histogram.axis.Bin(n_or_arr, lo=None, hi=None, *, name='', label='')

Bases: DenseAxis

Super class for dense axes.

A binned axis with name, label, and binning.

Parameters:
  • n_or_arr (int or list or np.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

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

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

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)

property _intervals
_ireduce(the_slice)
centers(flow=False)

Bin centers

Parameters:

flow (bool)

edges(flow=False)

Bin boundaries

Parameters:

flow (bool)

identifiers(flow=False)

List of Interval identifiers

index(identifier)

Index of a identifier or label

Parameters:

identifier (float or Interval or np.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

property size

Number of bins

class cuda_histogram.axis.Interval(lo, hi, label=None)

Bases: object

Real number interval

Totally ordered, assuming no overlap in intervals. A special nan interval can be constructed, which is defined as greater than [*, inf)

Parameters:
  • lo (float) – Bin lower bound, inclusive

  • hi (float) – Bin upper bound, exclusive

property hi

Upper boundary of this bin, exclusive

property label

Label of this bin, mutable

property lo

Lower boundary of this bin, inclusive

property mid

Midpoint of this bin

nan()
class cuda_histogram.axis.Regular(bins, start, stop, *, name='', label='')

Bases: Bin

Make a regular axis with nice keyword arguments for underflow, overflow, and growth.

Parameters:
  • bins (int) – The number of bins between start and stop.

  • start (float) – The beginning value for the axis.

  • stop (float) – The ending value for the axis.

  • name (str) – Axis name.

  • label (str) – Axis label.

reduced(islice)

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

class cuda_histogram.axis.Variable(edges, *, name='', label='')

Bases: Bin

Make an axis with irregularly spaced bins. Provide a list or array of bin edges, and len(edges)-1 bins will be made.

Parameters:
  • edges (Array[float]) – The edges for the bins. There will be one less bin than edges.

  • name (str) – Axis name.

  • label (str) – Axis label.

reduced(islice)

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