fix handling of case where idx is negative#8174
fix handling of case where idx is negative#8174will-cern wants to merge 2 commits intoroot-project:masterfrom
Conversation
…e access from the back
|
Can one of the admins verify this patch? |
|
Hi Will! We try to bring the behavior of the Only the So bringing the element-accessing behavior closer to Python behavior would unfortunately bring us further away from the STL behavior, and I would advise against the suggested change. However, I would agree that on the pyROOT side, the Is that a fair compromise? Did you intend to use the negative indices in C++? |
|
This sounds good to me, yes this is purely for the pythonization, if there's a dedicated place where that is coded up then yes supporting it there (with an exception if trying to access invalid index) would be great! Atm it's very user un-friendly that ROOT crashes if we access an index out of range in pyROOT |
|
Okay, very good! Just FYI, the pythonizations are implemented in these "mirror classes" that I declared here: Every function that is defined in a mirror class is then bound to the actual RooFit class, with the original cppyy function name changed to have an underscore prefix. I have already a PR open with some more pythonizations of RooAbsCollection: #8179. I can just add one more commit with the element access. But in general, I'm not working too much on these pythonizations because we will most likely get a Google summer of code student for that project! So if you have any further nice ideas for RooFit pythonizations, feel free to write them down in this issue and I will what can be implemented with the student. |
I noticed that RooArgList doesn't handle the case where idx is negative. But also thought it would be nice to add support for use of negative numbers to access the list from the back, so it behaves like a python list in this respect
I noticed that there is nice operator[] behavior in 6.24 (uses at and throws exception) but this isn't in master???