Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/boost_histogram/_internal/hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def _compute_inplace_op(
)
)
else:
view = self.view(flow=False)
view = self.view(flow=True)
getattr(view, name)(other)
self._variance_known = False
return self
Expand Down
2 changes: 1 addition & 1 deletion tests/test_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ def test_add_broadcast():

h2 = h + [[1]]
assert h2.sum() == 10 * 20
assert h2.sum(flow=True) == 10 * 20
assert h2.sum(flow=True) == 12 * 22

h3 = h + np.ones((10, 20))
assert h3.sum() == 10 * 20
Expand Down
26 changes: 26 additions & 0 deletions tests/test_histogram_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,3 +429,29 @@ def test_single_flow_bin():
assert h[3::sum] == 1

assert h[1:2][sum] == 5


# issue 579


def test_scale_flowbins():
w = 1e-1
x = np.random.normal(loc=0.4, scale=0.4, size=100)

h = bh.Histogram(bh.axis.Variable([0, 0.5, 1]), storage=bh.storage.Weight())

h.fill(x, weight=w)

ref_value = h.values(flow=True) * 5
scale_value = (h * 5).values(flow=True)

assert scale_value == approx(ref_value)


def test_add_flowbins():
h = bh.Histogram(bh.axis.Variable([0, 0.5, 1]), storage=bh.storage.Weight())

ref_value = h.values(flow=True) + 5
scale_value = (h + 5).values(flow=True)

assert scale_value == approx(ref_value)