[RF] Make the code emitted by codegen locale-independent - #23210
Open
guitargeek wants to merge 1 commit into
Open
[RF] Make the code emitted by codegen locale-independent#23210guitargeek wants to merge 1 commit into
guitargeek wants to merge 1 commit into
Conversation
The codegen backend formats the numbers it writes into the generated C++ with default-constructed streams, which follow the global locale. Under a comma-decimal locale (a German one, say) the emitted literals came out as "0,5": that does not compile, and inside a call argument list the comma even turns one argument into two, so the generated code silently changes meaning instead of failing. Imbue the classic locale on every stream whose output ends up in the generated code: CodegenImpl's doubleToString(), which formats the value of RooConstVar/RooRealVar and the analytical integrals, plus CodegenContext's buildArg() for double arguments, buildArgSpanImpl() for the emitted arrays (where a grouping separator would corrupt integers the same way), and the stream that renders the node descriptions into the code comments. Add a regression test that generates the code for a RooGaussian with constant parameters and for a RooChebychev (whose observable range is passed to the generated call as a plain double) under a comma-decimal locale, built from a custom numpunct facet because no such OS locale is installed everywhere. Both must produce exactly the code they produce under the classic locale. This is the first test for the codegen package, so it also adds roofit/codegen/test/. 🤖 Done with the help of AI
Test Results 21 files 21 suites 3d 12h 45m 18s ⏱️ For more details on these failures, see this check. Results for commit 77488f1. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The codegen backend formats the numbers it writes into the generated C++ with default-constructed streams, which follow the global locale. Under a comma-decimal locale (a German one, say) the emitted literals came out as "0,5": that does not compile, and inside a call argument list the comma even turns one argument into two, so the generated code silently changes meaning instead of failing.
Imbue the classic locale on every stream whose output ends up in the generated code: CodegenImpl's doubleToString(), which formats the value of RooConstVar/RooRealVar and the analytical integrals, plus CodegenContext's buildArg() for double arguments, buildArgSpanImpl() for the emitted arrays (where a grouping separator would corrupt integers the same way), and the stream that renders the node descriptions into the code comments.
Add a regression test that generates the code for a RooGaussian with constant parameters and for a RooChebychev (whose observable range is passed to the generated call as a plain double) under a comma-decimal locale, built from a custom numpunct facet because no such OS locale is installed everywhere. Both must produce exactly the code they produce under the classic locale. This is the first test for the codegen package, so it also adds roofit/codegen/test/.
🤖 Done with the help of AI