Skip to content

Commit

Permalink
fix: preserve flow when rebinning
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejnovak committed Jan 31, 2025
1 parent c040a66 commit bac117a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/boost_histogram/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,18 +975,18 @@ def __getitem__(self: H, index: IndexingExpr) -> H | float | Accumulator:

new_reduced = reduced.__class__(axes)
new_view = new_reduced.view(flow=True)

j = 1
j = 0
groups = [1] + groups + [1] # pad for flow bins
for new_j, group in enumerate(groups):
for _ in range(group):
pos = [slice(None)] * (i)
if new_view.dtype.names:
for field in new_view.dtype.names:
new_view[(*pos, new_j + 1, ...)][field] += (
new_view[(*pos, new_j, ...)][field] += (
reduced_view[(*pos, j, ...)][field]
)
else:
new_view[(*pos, new_j + 1, ...)] += reduced_view[
new_view[(*pos, new_j, ...)] += reduced_view[
(*pos, j, ...)
]
j += 1
Expand Down

0 comments on commit bac117a

Please sign in to comment.