-
Notifications
You must be signed in to change notification settings - Fork 67
Avoid misleading error message by return 0 for numbaskets if interpretation is None #420
Conversation
Wow, thank you! This is not the solution I was thinking of (I was thinking of just preventing the error message), but this might be a better choice. I'd like to merge this on Monday to give myself some time to think of possible consequences of claiming that a branch has zero baskets. (Some branches have |
I see! You’re the architect ; ) |
No, we can't do this. If there's a new type we're unfamiliar with, the This would also happen with another potential solution (something I was thinking about after seeing yours) in which we set the The only way to do this correctly is to put the check immediately before the error message: changed to else if self.interpretation is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requested changes in a comment.
Yes, actually that was my first approach, however I encountered more errors since ~/Dev/uproot/uproot/tree.py in numbaskets(self)
990 if self._recoveredbaskets is None:
991 self._tryrecover()
--> 992 return self._numgoodbaskets + len(self._recoveredbaskets)
993
994 def _cachekey(self, interpretation, entrystart, entrystop):
TypeError: object of type 'NoneType' has no len() I just pushed your change request. I could not manage to create a small enough file yet to reproduce, but I'll try. I however assume that we already have some samples in the repo, I'll check them first. |
Oh, sorry—in that case where |
Makes sense 😉 |
Alright: In [1]: import uproot
In [2]: f = uproot.open("KM3NeT_00000044_00006772_n10.root")
In [3]: f[b'KM3NET_TIMESLICE_L0;2'][b'km3net_timeslice_L0'].uncompressedbytes()
Out[3]: 0 I however would like to cover this with a test... |
I can wait. There are a few sample files in They only didn't trigger an error before because we never tried to access one of the structure branches, one of the branches that should have |
I've been deploying new releases of awkward, uproot-methods, and uproot, and in some cases, finding a backlog of bug-fixes that have been waiting a while for a new release (uproot-methods had about 5 of them). In uproot, Oksana's addition of ZSTD as a decompression algorithm is a big enough change to increase the middle digit of the version number. I just deployed new versions of awkward and uproot-methods, and I'd like to include your fix of this error message in the uproot deployment. If it's likely to be ready today, I'll wait—otherwise, I'll release this now and do a bug-fix release later when you're done. Do you know if I should wait or just deploy now? Thanks! |
Hey Jim! Sorry I had a busy day, I can follow up tomorrow, but feel free to merge if you are happy with the change and I add the tests the next day. I don't want to block the release pipeline... |
OK, test is there. I have however two failing tests, which also fail on upstream/master. I'll follow up with an issue. |
I'm not sure what's happening in your local tests, but it looks fine and passes tests. Event.root is a large file that we test remotely with HTTP. |
With reference to #419 (comment) this is a tiny patch which avoids a misleading error message when trying to call e.g.
.uncompressedbytes()
on a branch with no data (i.e.interpretation is None
).Not sure if you are happy with this, to me it seemed that returning 0 in the
numbaskets
@property
should be enough to also avoid further confusions, if I understood correctly.Anyways, at least we now have a todo entry, as you wanted @jpivarski 😉