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

fix TH1 repr when _fName attr is not set #65

Closed phylsix closed 5 years ago

phylsix commented 5 years ago

This is trying to fix:

>>> import numpy as np
>>> hnp = np.histogram(range(10))
>>> from uproot_methods.classes.TH1 import from_numpy
>>> from_numpy(hnp)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/uscms_data/d3/wsi/lpcdm/uproot-methods/uproot_methods/classes/TH1.py", line 15, in __repr__
    if self._fName is None:
AttributeError: 'TH1' object has no attribute '_fName'
jpivarski commented 5 years ago

Okay, I followed this and see that the name property does the proper check for getattr(self, "_fName", None), so this should always work.

Thanks for finding it!