[RF][HS3] Don't let evauation artifacts demote top-level pdfs in the export - #23224
Open
guitargeek wants to merge 2 commits into
Open
[RF][HS3] Don't let evauation artifacts demote top-level pdfs in the export#23224guitargeek wants to merge 2 commits into
guitargeek wants to merge 2 commits into
Conversation
The HS3 exporter and `RooJSONFactoryWSTool::cleanWS()` used `!hasClients()` as the criterion for "this pdf or function is a top-level object of the workspace". But RooFit also registers objects that live outside the workspace as clients: the normalization integral that `RooAbsPdf` caches after `getVal(normSet)`, or the integral returned by `createIntegral()`. A single normalized evaluation before the export therefore silently produced a document without any distributions, domains or parameter values, while `exportJSON()` still returned `true`. Only count clients that are actually components of the workspace, since these are the ones that make an object a sub-node of a bigger model. Closes root-project#23221. 🤖 Done with the help of AI
Behaviour-preserving cleanup of roofit/hs3, motivated by keeping the line count in check after the fix for root-project#23221: * Build error messages with string concatenation instead of a `std::stringstream` whose only purpose is to feed `error()`, and drop the `return`s after `error()`, which is `[[noreturn]]`. * Share the "find the category observable" loop between the two dataset export functions, and the name-index construction between "functions" and "distributions". * HistFactory: factor out the repeated modifier node creation and the constraint queueing loops, drop the unreachable "optionally" branch of `optionallyExportGammaParameters()` (`forceExport` was always true), merge `hasStaterror()` into `findStaterror()`, and drop a `std::map` presence check that `operator[]` already covers. * RooFitCore: `readBinning()` reimplemented `RooJSONFactoryWSTool::readAxes()`, the RealSumPdf/RealSumFunc importer and exporter pairs are now templates, `writePolynomialBody()` is inlined into its single caller, and the manual `push_back` loops use the existing `operator<<` for JSON sequences. * Drop unused includes and dead locals. Verified that the exported JSON for HistFactory, RealSum, Polynomial, Spline and ParamHistFunc models is byte-identical before and after. 🤖 Done with the help of AI
Test Results 23 files 23 suites 3d 18h 53m 59s ⏱️ For more details on these failures, see this check. Results for commit 7053a31. |
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 HS3 exporter and
RooJSONFactoryWSTool::cleanWS()used!hasClients()as the criterion for "this pdf or function is a top-level object of the workspace". But RooFit also registers objects that live outside the workspace as clients: the normalization integral thatRooAbsPdfcaches aftergetVal(normSet), or the integral returned bycreateIntegral(). A single normalized evaluation before the export therefore silently produced a document without any distributions, domains or parameter values, whileexportJSON()still returnedtrue.Only count clients that are actually components of the workspace, since these are the ones that make an object a sub-node of a bigger model.
Closes #23221.
🤖 Done with the help of AI
A second commit does some refactors to keep the total number of lines of code under control.