scikit-hep / hist

Histogramming for analysis powered by boost-histogram
https://hist.readthedocs.io
BSD 3-Clause "New" or "Revised" License
127 stars 25 forks source link

[BUG] cannot subtract histograms with Weight() storage #427

Open goi42 opened 2 years ago

goi42 commented 2 years ago

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 commented 2 years ago

The same issue arrises with multiplication and division:

h_w * h_w
h_w / h_w
JMulder99 commented 1 year ago

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.