TTree::GetEntry() entry parameter default value fix#8425
TTree::GetEntry() entry parameter default value fix#8425pcanal merged 6 commits intoroot-project:masterfrom
Conversation
|
Can one of the admins verify this patch? |
tree/tree/src/TTree.cxx
Outdated
| // through the friends tree, let return | ||
| if (kGetEntry & fFriendLockStatus) return 0; | ||
|
|
||
| if (!entry) { |
There was a problem hiding this comment.
zero is a valid value!!! It is the 'first' entry per se.
There was a problem hiding this comment.
But doesn't !entry mean that no value for entry was provided?
There was a problem hiding this comment.
Nope. The user can provide 0 explicitly and there is no way of seeing the difference. And since 0 is the first entry, it will be almost always being passed the first time GetEntry is called :)
tree/tree/inc/TTree.h
Outdated
| virtual Long64_t GetEstimate() const { return fEstimate; } | ||
| virtual Int_t GetEntry(Long64_t entry = 0, Int_t getall = 0); | ||
| virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0); | ||
| Int_t GetEvent(Long64_t entry = 0, Int_t getall = 0) { return GetEntry(entry, getall); } |
There was a problem hiding this comment.
If we update GetEntry we should probably also update GetEvent
There was a problem hiding this comment.
Okay. Does that mean I should reopen this PR?
|
@pcanal I have thought of a "solution". If we remove the default value, set |
|
I am not sure how this would work. Can you make a concrete (code) proposal? |
I had something like this in mind: So the declarations in TTree.h remain unchanged, i.e. 0 is the default value for ´entry´ However, by adding this line to both GetEntry() and GetEvent() in TTree.cxx: |
|
Well, wouldn't that issue a spurrious/wrong warning in the following case (i.e the normal usage): [Slightly related question, did you run any of the test after successfully compiling?] |
|
@phsft-bot build just on ROOT-performance-centos8-multicore/default |
|
Starting build on |
Actually I had some trouble compiling in my usual manor. But when I tried to compile upstream/master it also failed so the failure didn't seem to originate from my chnages. I wasnt sure what to do so I was hoping I could see what phsft-bot has to say before I do anything. This is how I build: (Ubuntu 20.04 LTS) |
But here the user would be providing a value for |
|
|
Ohh I didn't know that. Then maybe one could simply check if entry is undefined. Or does that cause the same error? |
|
Build failed on ROOT-performance-centos8-multicore/default. Failing tests:
And 141 more |
|
Is this because 0 is no longer the default value? |
|
There is no "undefined" value for an integer variable. The test failures are because with these changes we are printing errors that were not printed before. |
Ah ok |
pcanal
left a comment
There was a problem hiding this comment.
Please remove the if (!entry) test and associated warning.
Please also change the signature of GetEvent.
okay. But I did some internet research and couldn't find a way to check if no entry parameter was given by the user without also raising the error when the user enters 0 (since !entry == true if entry == 0) |
|
If we wanted to catch those cases, we would just add a new overload but I don't think it is necessary/needed. |
Co-authored-by: Philippe Canal <[email protected]>
|
@phsft-bot build |
|
Starting build on |
|
Build seems to have succeeded. |
|
Thank you very much! |
Thank you for your help. I learn something new with every PR :D |
|
Final note: In the commits left on the branch there was a "merge" commit, we want to avoid them. When updating your branch with the content of the master branch, please use 'git rebase' rather than For this PR, I effectively handled these changes by doing a "merge and squash" but this works out only for PR that have one effective commit (the case here). |
Ah ok. I recently learned what rebase -i is, so I'll use that next time. Thanks for the tip |
|
@AdvaitDhingra This is a breaking change (we want it, it's still a breaking change). Could you add a note in |
Would that require a separate PR? |
Yes, please! |
Okay I'll get started :D |
|
@Axel-Naumann can I also add my name to the list of contributors? |
We really appreciate small fixes like those, but we generally only call out the authors of larger / continuous contributions. We'll think of another way to show our appreciation! :-) |
Ah ok, that makes sense 😅. I'll make the PR now. |
Remove default value for the entry parameter in TTree::GetEntry and GetEvent.
This Pull request:
Changes or fixes:
I fixed the issue, where if no value for entry was provided, it would automatically set to 0. This has the result that the user has many outputs that correspond to the 0th entry.
Checklist:
This PR fixes #8300