Skip to content

Conversation

@guitargeek
Copy link
Contributor

@guitargeek guitargeek commented Jan 10, 2023

The different overloads of RooAbsRealLValue::inRange() implemented
different tolerances when checking if a value x falls inside a
specific range. Some overloads checked if the interval
[x - 1e-6, x + 1e6] is overlapping with the range, an other overload
checked if the interval [x - 1e-8*x, x + 1e8*x] is overlapping.

It's better is this is done consistently and predictably so this commit
suggests to leave out these epsilon margins that were never documented.
For backwards compatibility, one can set a custom relative or absolute
epsilon via the RooNumber interface.

Also, the checks if the range limits are RooNumber::isInfinite() were
removed. They were mathematically redundant, since in RooFit, +/-
infinity is simply defined as +/-1e30.

This PR fixes some corner cases in which you get paradox results from rage checks, like in this example:

    RooRealVar x{"x", "x", 1e-6, 2e-6};
    RooRealVar y{"y", "y", 1e30, 1e30};

    std::cout << x.inRange(0.0, nullptr) << std::endl;
    std::cout << y.inRange(0.0, nullptr) << std::endl;
    // both checks will return true without this PR!

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Build failed on mac12/noimt.
Running on macphsft17.dyndns.cern.ch:/Users/sftnight/build/jenkins/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-10T12:03:17.915Z] FAILED: roofit/roofitcore/CMakeFiles/RooFitCore.dir/src/RooAbsRealLValue.cxx.o
  • [2023-01-10T12:03:19.281Z] /Users/sftnight/build/jenkins/workspace/root-pullrequests-build/root/roofit/roofitcore/src/RooAbsRealLValue.cxx:78:15: error: static_assert expression is not an integral constant expression

Warnings:

  • [2023-01-10T12:02:23.787Z] /Users/sftnight/build/jenkins/workspace/root-pullrequests-build/root/core/base/src/TDirectory.cxx:1245:7: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]

@root-project root-project deleted a comment from phsft-bot Jan 10, 2023
@root-project root-project deleted a comment from phsft-bot Jan 10, 2023
@phsft-bot
Copy link

Build failed on windows10/cxx14.
Running on null:C:\build\workspace\root-pullrequests-build
See console output.

Errors:

  • [2023-01-10T12:45:21.570Z] C:\build\workspace\root-pullrequests-build\root\roofit\roofitcore\src\RooAbsRealLValue.cxx(62,16): error C3615: constexpr function '`anonymous-namespace'::inRangeImpl' cannot result in a constant expression [C:\build\workspace\root-pullrequests-build\build\roofit\roofitcore\RooFitCore.vcxproj]
  • [2023-01-10T12:45:21.571Z] C:\build\workspace\root-pullrequests-build\root\roofit\roofitcore\src\RooAbsRealLValue.cxx(79,89): error C2131: expression did not evaluate to a constant [C:\build\workspace\root-pullrequests-build\build\roofit\roofitcore\RooFitCore.vcxproj]

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Build failed on windows10/cxx14.
Running on null:C:\build\workspace\root-pullrequests-build
See console output.

Errors:

  • [2023-01-10T13:58:32.298Z] C:\build\workspace\root-pullrequests-build\root\roofit\roofitcore\src\RooAbsRealLValue.cxx(62,16): error C3615: constexpr function '`anonymous-namespace'::inRangeImpl' cannot result in a constant expression [C:\build\workspace\root-pullrequests-build\build\roofit\roofitcore\RooFitCore.vcxproj]

@phsft-bot
Copy link

Build failed on mac11/cxx14.
Running on macphsft23.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-10T15:18:24.120Z] FAILED: roofit/roofitcore/CMakeFiles/RooFitCore.dir/src/RooAbsRealLValue.cxx.o
  • [2023-01-10T15:18:25.487Z] /Users/sftnight/build/workspace/root-pullrequests-build/root/roofit/roofitcore/src/RooAbsRealLValue.cxx:62:16: error: constexpr function never produces a constant expression [-Winvalid-constexpr]

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Build failed on mac12/noimt.
Running on macphsft17.dyndns.cern.ch:/Users/sftnight/build/jenkins/workspace/root-pullrequests-build
See console output.

Warnings:

  • [2023-01-10T15:36:59.366Z] /Users/sftnight/build/jenkins/workspace/root-pullrequests-build/root/core/base/src/TDirectory.cxx:1245:7: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]

Failing tests:

And 63 more

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@guitargeek guitargeek changed the title [RF] Make the RooAbsRealLValue::inRange() overloads consistent [RF] Make margin in RooAbsRealLValue::inRange() zero by default Jan 10, 2023
The different overloads of `RooAbsRealLValue::inRange()` implemented
different tolerances when checking if a value `x` falls inside a
specific range. Some overloads checked if the interval
`[x - 1e-6, x + 1e6]` is overlapping with the range, an other overload
checked if the interval `[x - 1e-8*x, x + 1e8*x]` is overlapping.

It's better is this is done consistently and predictably so this commit
suggests to leave out these epsilon margins that were never documented.
For backwards compatibility, one can set a custom relative or absolute
epsilon via the `RooNumber` interface.
@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Build failed on mac12/noimt.
Running on macphsft17.dyndns.cern.ch:/Users/sftnight/build/jenkins/workspace/root-pullrequests-build
See console output.

Warnings:

  • [2023-01-10T18:10:50.806Z] /Users/sftnight/build/jenkins/workspace/root-pullrequests-build/root/core/base/src/TDirectory.cxx:1245:7: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]

Failing tests:

And 63 more

Copy link
Member

@lmoneta lmoneta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
I have a comment on RooNumber::_Infinity.
I think every compiler has numeric_limits now, so one can remove the ifdef, which is not defined.
If you don't want to use infinity (I don't think there reasons not to do this), then I think is better using std::numeric_limits<double>::max(). 1.E30 is std::numeric_limits<float>::max().

@guitargeek
Copy link
Contributor Author

Okay! I will try out this change with infinity later later

@guitargeek guitargeek merged commit 4863727 into root-project:master Jan 11, 2023
@guitargeek guitargeek deleted the rangecheck_1 branch January 11, 2023 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants