hist icon indicating copy to clipboard operation
hist copied to clipboard

[BUG] cannot subtract histograms with Weight() storage

Open goi42 opened this issue 2 years ago • 2 comments

Trying to subtract histograms with Weight() storage raises an error:

AttributeError: 'boost_histogram._core.hist.any_weight' object has no attribute '__isub__'

Reproducer:

import hist

assert hist.__version__ == "2.6.1"
ax = hist.axis.Regular(5, 0, 5)
h_d = hist.Hist(ax, storage=hist.storage.Double())
h_w = hist.Hist(ax, storage=hist.storage.Weight())
values = [1, 2, 3, 4]
h_d.fill(values)
h_w.fill(values)
h_d - h_d  # no problem
h_w + h_w  # no problem
h_d - h_w  # no problem
h_w - h_d  # problem

goi42 avatar Jul 07 '22 14:07 goi42

The same issue arrises with multiplication and division:

h_w * h_w
h_w / h_w

goi42 avatar Jul 07 '22 15:07 goi42

Indeed, the same happens when dividing two (2d) histograms: AttributeError: 'boost_histogram._core.hist.any_weight' object has no attribute '__itruediv__'

I think this is rather a boost_histogram issue.

JMulder99 avatar Jan 20 '23 12:01 JMulder99