scikit-hep / uproot3-methods

Pythonic behaviors for non-I/O related ROOT classes.
BSD 3-Clause "New" or "Revised" License
21 stars 28 forks source link

TH3 not writeable #76

Closed jrueb closed 4 years ago

jrueb commented 4 years ago

When I try write a TH3 to a file, I get TypeError: type TH3 from module __main__ is not writeable by uproot

I took a look at convert.py from uproot_methods and it seems there are lines for TH1 and TH2 but not for TH3. I added the two lines

elif any(x == ("uproot_methods.classes.TH3", "Methods") or x == ("TH3", "Methods") for x in types(obj.__class__, obj)):
 return (None, None, "uproot.write.objects.TH", "TH")

and it worked. And reason why these lines aren't in there? Could they be added?

reikdas commented 4 years ago

Hey :)

No, there is no specific reason that the lines aern't there - we just forgot to add it in when adding support for writing TH3. Thanks for catching the mistake.

Feel free to create a PR which adds those lines.

jpivarski commented 4 years ago

@reikdas, TH3 was included in your implementation, right? I think uproot-methods just needs to be updated to be aware of the capabilities of uproot.

reikdas commented 4 years ago

@jpivarski Yes. Without the missing uproot-methods code, uproot can just write TH3s that are already available (aka TH3s read by uproot).