Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization for number of histogram entries #1276

Open
alexander-held opened this issue Aug 22, 2024 · 0 comments
Open

Serialization for number of histogram entries #1276

alexander-held opened this issue Aug 22, 2024 · 0 comments
Labels
bug (unverified) The problem described would be a bug, but needs to be triaged

Comments

@alexander-held
Copy link
Member

alexander-held commented Aug 22, 2024

When creating a histogram with ROOT and serializing it with uproot, the GetEntries() (number of times it has been filled) count does not seem to get serialized correctly:

import ROOT
import uproot

h = ROOT.TH1D('h', 'h', 10, 0, 1)
h.Sumw2()
h.Fill(0.2, 0.1)
h.Fill(0.4, 0.5)
assert h.GetEntries() == 2.0

# save with uproot, load with ROOT
with uproot.recreate("tmp.root") as f:
    f["h"] = h

g = ROOT.TFile.Open("tmp.root")
print(g["h"].GetEntries())  # this is 0.6 now, but should be 2

This was tested with uproot 5.3.10.

I originally ran into this when testing the serialization of hist histograms instead:

import hist

h = hist.Hist.new.Reg(10, 0, 1).Weight()
h.fill([0.2, 0.4], weight=[0.1, 0.5])

For this setup, the GetEntries() (after saving with uproot and loading with ROOT) similarly ends up being 0.6 but I am not sure if boost-histogram has this kind of property in the first place.

@alexander-held alexander-held added the bug (unverified) The problem described would be a bug, but needs to be triaged label Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (unverified) The problem described would be a bug, but needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant