You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-19Lines changed: 21 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,12 +26,11 @@ For the moment, you need to uninstall and reinstall to ensure you have the lates
26
26
27
27
## Usage
28
28
29
-
This is a suggested example of usage.
30
29
31
30
```python
32
31
import boost_histogram as bh
33
32
34
-
# Compose axis however you like
33
+
# Compose axis however you like; this is a 2D histogram
35
34
hist = bh.histogram(bh.axis.regular(2, 0, 1),
36
35
bh.axis.regular(4, 0.0, 1.0))
37
36
@@ -53,21 +52,25 @@ counts = hist.view()
53
52
*`bh.axis.regular_pow(n, start, stop, power)`: Regularly spaced value to some `power`
54
53
*`bh.axis.integer(start, stop, underflow=True, overflow=True, growth=False)`: Special high-speed version of `regular` for evenly spaced bins of width 1
55
54
*`bh.axis.variable([start, edge1, edge2, ..., stop], underflow=True, overflow=True)`: Uneven bin spacing
56
-
*`bh.axis.category([...], growth=False)`: Integer or (WIP) string categories
55
+
*`bh.axis.category([...], growth=False)`: Integer or string categories
57
56
* Axis features:
57
+
*`.index(values)`: The index at a point (or points) on the axis
58
+
*`.value(indexes)`: The value for a fractional bin in the axis
59
+
*`.bin(i)`: The bin given an integer index
60
+
*`.options`: The options the axis was created with
61
+
*`.metadata`: Anything a user wants to store
62
+
*`.size`: The number of bins (not including under/overflow)
63
+
*`.extent`: The number of bins (including under/overflow)
58
64
*`.bin(i)`: The bin or a bin view for continuous axis types
59
65
*`.lower()`: The lower value
60
66
*`.upper()`: The upper value
61
67
*`.center()`: The center value
62
68
*`.width()`: The bin width
63
-
*`.bins()`: A list of bins or bin views
64
-
*`.size()`: The number of bins (not including under/overflow)
65
-
*`.size(flow=True)`: The number of bins (including under/overflow)
66
69
*`.options()`: The options set on the axis (`bh.axis.options` bitfields)
67
-
*`.edges(flow=False)`: The N+1 bin edges (if continuous)
68
-
*`.centers(flow=False)`: The N bin centers (if continuous)
69
-
*`.index(values)`: The index at a point (or points) on the axis
70
-
*`.value(index)`: The value for a fractional bin in the axis
70
+
*`.edges`: The N+1 bin edges (if continuous)
71
+
*`.centers`: The N bin centers (if continuous)
72
+
*`.widths`: The N bin widths
73
+
71
74
* Many storage types
72
75
*`bh.storage.int`: 64 bit unsigned integers for high performance and useful view access
73
76
*`bh.storage.double`: Doubles for weighted values
@@ -82,30 +85,29 @@ counts = hist.view()
82
85
*`bh.accumulator.sum`: High accuracy sum (Neumaier)
83
86
*`bh.accumulator.mean`: Running count, mean, and variance (Welfords's incremental algorithm)
84
87
* Histogram operations
85
-
*`.fill(arr, ..., weight=...)` Fill with N arrays or single values
86
-
*`(a, b, ...)`: Fill with arrays or single values
87
-
*`+`: Add two histograms
88
-
*`.rank()`: The number of dimensions
89
-
*`.size()`: The number of bins (include under/overflow bins)
88
+
*`h.fill(arr, ..., weight=...)` Fill with N arrays or single values
89
+
*`h.rank`: The number of dimensions
90
+
*`h.size or len(h)`: The number of bins
90
91
*`.reset()`: Set counters to 0
92
+
*`+`: Add two histograms
91
93
*`*=`: Multiply by a scaler (not all storages) (`hist * scalar` and `scalar * hist` supported too)
92
94
*`/=`: Divide by a scaler (not all storages) (`hist / scalar` supported too)
93
95
*`.to_numpy(flow=False)`: Convert to a numpy style tuple (with or without under/overflow bins)
94
96
*`.view(flow=False)`: Get a view on the bin contents (with or without under/overflow bins)
95
-
*`np.asarray(...)`: Get a view on the bin contents with under/overflow bins
96
97
*`.axis(i)`: Get the `i`th axis
97
-
*`.at(i, j, ...)`: Get the bin contents as a location
98
-
*`.sum()`: The total count of all bins
98
+
*`.sum(flow=False)`: The total count of all bins
99
99
*`.project(ax1, ax2, ...)`: Project down to listed axis (numbers)
100
100
*`.reduce(ax, reduce_option, ...)`: shrink, rebin, or slice, or any combination
101
+
<!--
101
102
* `.indexed(flow=False)`: Iterate over the bins with a special "indexed" iterator
102
103
* `ind.content`: The contents of a bin (set or get)
103
104
* `ind.bins()`: A list of bins
104
105
* `ind.centers()`: The centers of each bin
105
106
* `ind.indices()`: A list of indices
107
+
-->
108
+
* Indexing - Supports the Unified Histogram Indexing (UHI) proposal
106
109
* Details
107
110
* Use `bh.histogram(..., storage=...)` to make a histogram (there are several different types)
108
-
* Several common combinations are optimized, such as regular axes + int storage
0 commit comments