Skip to content

Commit

Permalink
Added hasattr check to NanoAODEvents __repr__
Browse files Browse the repository at this point in the history
  • Loading branch information
pviscone committed Oct 15, 2023
1 parent 1aa0fbd commit 881ec08
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/coffea/nanoevents/methods/nanoaod.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@

class _NanoAODEvents(behavior["NanoEvents"]):
def __repr__(self):
return f"<event {self.run}:{self.luminosityBlock}:{self.event}>"

if (hasattr(self,"run") and
hasattr(self,"luminosityBlock") and
hasattr(self,"event")):
return f"<event {self.run}:{self.luminosityBlock}:{self.event}>"
else:
return "<event>"

behavior["NanoEvents"] = _NanoAODEvents

Expand Down

0 comments on commit 881ec08

Please sign in to comment.