File: banner_slides.md

package info (click to toggle)
python-boost-histogram 1.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,236 kB
  • sloc: python: 7,940; cpp: 3,243; makefile: 22; sh: 1
file content (108 lines) | stat: -rw-r--r-- 2,036 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
aspectratio: 169
fontfamily: bookman
orphan: true
---

# Simple usage

<!--
Build with:
pandoc docs/banner_slides.md -t beamer -o banner_slides.pdf

Converted to GIF with ezgif.com, 300 ms delay time.
-->

```python
import boost_histogram as bh

# Make a histogram
h = bh.Histogram(bh.axis.Regular(10, 0, 1))

# Fill it with events
h.fill([0.2, 0.3, 0.6, 0.9])

# Compute the sum
total = h.sum()
```

# Advanced Indexing

```python
# Slice in data coordinates
sliced_h = h[bh.loc(0.5) : bh.loc(1.5)]

# Sum over and rebin easily
smaller = h[::sum, :: bh.rebin(2)]

# Set and access easily
h[...] = np.asarray(prebinned)

# Project and reorder axes
h2 = h.project(1, 0)
```

# Many Axis types

::: columns
::: {.column width="60%"}

- Regular: evenly or functionally spaced binning
- Variable: arbitrary binning
- Integer: integer binning
- IntCategory: arbitrary integers
- StrCategory: strings
- Boolean: True/False

Most Axis types support optional extras:

- Underflow and/or Overflow bins
- Growth
- Circular (wraparound)

:::
::: {.column width="40%"}

\begin{center}
\includegraphics[width=1.05\textwidth]{docs/\_images/axis_circular.png}
\includegraphics[width=.7\textwidth]{docs/\_images/axis_regular.png}
\includegraphics[width=.9\textwidth]{docs/\_images/axis_variable.png}
\includegraphics[width=.65\textwidth]{docs/\_images/axis_integer.png}
\includegraphics[width=\textwidth]{docs/\_images/axis_category.png}
\end{center}

:::
:::

# Advanced Storages

- Integers
- Floats
- Weighted Sums
- Means
- Weighted Means

Supports the UHI `PlottableHistogram` protocol!

```python
import mplhep

mplhep.histplot(h)
```

# NumPy compatibility

```python
# Drop in faster replacement
H, edges = bh.numpy.histogram(data)

# Drop in threaded faster replacement
H, edges = bh.numpy.histogram(data, threads=4)

# Drop in much faster replacement for 2D+
H, e1, e2 = bh.numpy.histogram2d(xdata, ydata)

# Return a Histogram, convert back to NumPy style
h = bh.numpy.histogram(data, histogram=bh.Histogram)
H, edges = h.to_numpy()
```