fix: not all branchid_interpretation are necessarily in ranges_or_baskets #1202
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an addendum to PR #838, which fixed #833 by checking for
CannotBeAwkward
errors earlier (before reading data).The previous PR added a
TBranch._awkward_check
on all TBranches inbranchid_interpretation
, but since there wasn't a list of actual TBranch objects (with methods like_awkward_check
that you can call), the previous PR made a lookup dict calledbranchid_to_branch
for this purpose, getting theTBranch.cache_key
("branch id") to TBranch object mapping fromranges_or_baskets
.However, it looks like
ranges_or_baskets
can have fewer branches thanbranchid_interpretation
. Obviously I didn't think so when I wrote PR #8381, but the bug @gordonwatts found can only have happened if this is the case. It doesn't seem implausible: thebranchid_interpretation
list is made by iterating over the user-providedexpressions
whileranges_or_baskets
includes only those branches that are really going to get downloaded, decompressed, and interpreted. It is plausible that a step in between filters them, though I can only see how filtering could go in this direction: morebranchid_interpretation
branches thanranges_or_baskets
branches.Given that, and the fact that the purpose of this code is just to raise an error earlier than it would get raised anyway, and the
branchid_to_branch
mapping is not used for anything else, I think it is safe and correct to simply patch this by skipping the branches inbranchid_interpretation
that aren't inranges_or_baskets
. That's all this PR does.Footnotes
Since fix: complain about CannotBeAwkward earlier, before reading data. #838 was itself a patch, made long after the original writing of the code, I can't say that I knew better then and had some good reason for thinking that
branchid_interpretation
andranges_or_baskets
should have exactly the same set of branches. ↩