uproot5 icon indicating copy to clipboard operation
uproot5 copied to clipboard

fix: writing TProfiles from hist

Open ariostas opened this issue 1 month ago • 3 comments

This PR adds some flexibility to the hist profiles that can be written to file. The old code was assuming ROOT histograms that were converted to hist with to_hist, which adds some metadata, but if the metadata was not present it just didn't work. Someone should double-check that I'm inputting the right data into to_TProfile. Closes #1531.

ariostas avatar Dec 03 '25 21:12 ariostas

@pfackeldey could you take a look at this since you're good with histograms?

ariostas avatar Dec 03 '25 21:12 ariostas

thanks, it seems to work, even if I have to simplify my original code. For example with storage=hist.storage.WeightedMean() it doesn't work #1533 and ND profiles are not supported #1534.

By the way, I get a warning

FutureWarning: .metadata was not set, returning None instead of Attribute error, boost-histogram 1.7+ will error.
  if obj.metadata is not None and "fSumw2" in obj.metadata.keys():

wiso avatar Dec 05 '25 09:12 wiso

Thank you, @wiso! I fixed the warning and the WeightedMean storage. I'll follow up on the ND profiles on a separate PR.

ariostas avatar Dec 05 '25 15:12 ariostas