-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[RF] Correctly treat variables with integer names in RooFormula #10105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Starting build on |
In case of named arguments, the RooFormula will replace the argument names with` x[0]` to `x[n]`. There are two things that can go wrong if RooFormula is not implemented right. First, if there is a variable named "x" it should only be substituted if the matching substring is not followed by "[", to not replace existing x[i]. Second, variables with integer names like "0" should only be substituted if the match is not followed by a "]", again to avoid replacing x[i]. This test checks that these cases are handled correctly. The second case was so far not dealt with correctly, but with this commit it is. A corresponding unit test was also implemented. The preprocessor commands in `RooFormula` were also reorganized slightly, such that one can test the `TPRegexp` backend simply by commenting out the `define ROOFORMULA_HAVE_STD_REGEX`.
e12a388 to
0644372
Compare
|
Starting build on |
|
Build failed on ROOT-ubuntu2004/soversion. Failing tests: |
lmoneta
left a comment
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.
LGTM!
Thank you the fix.
I have one general comment, do we really need to support variables which have integer names ?
This can be confusing and in my opinion people should avoid doing this, and if RooFit does internally we should set a name such as "v " + integerValue.
|
Hi @lmoneta, I agree with you that these number literal names are confusing, but I'm afraid we can't get rid of this without risking to break user code. It was always the case that the |
In case of named arguments, the RooFormula will replace the argument
names with
x[0]tox[n]. There are two things that can go wrong ifRooFormula is not implemented right. First, if there is a variable named
"x" it should only be substituted if the matching substring is not
followed by "[", to not replace existing x[i]. Second, variables with
integer names like "0" should only be substituted if the match is not
followed by a "]", again to avoid replacing x[i]. This test checks that
these cases are handled correctly.
The second case was so far not dealt with correctly, but with this
commit it is. A corresponding unit test was also implemented.
The preprocessor commands in
RooFormulawere also reorganizedslightly, such that one can test the
TPRegexpbackend simply bycommenting out the
define ROOFORMULA_HAVE_STD_REGEX.This pull request fixes an issue reported in the forum:
https://root-forum.cern.ch/t/a-strange-bug-in-rf708-bphysics-c/49152/2