Skip to content

Nicer output for tp_run() - #31

Open
foersterst wants to merge 7 commits into
treeppl:mainfrom
foersterst:tidy-output
Open

Nicer output for tp_run()#31
foersterst wants to merge 7 commits into
treeppl:mainfrom
foersterst:tidy-output

Conversation

@foersterst

@foersterst foersterst commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

tp_run() used to return a list built directly from the output JSON via jsonlite. That list was long and hard to read, and it always needed a tp_parse…() call afterward to become usable. This PR changes that. Now, tp_run() returns a tidy data frame produced by tp_parse_smc() or tp_parse_mcmc(), called internally for any model those two functions support (models that return trees still need dedicated parsers, which we haven't built yet).

tp_run() picks the right parser automatically, based on the inference method and model passed to tp_compile(). It reads that information from the sampler and decides which parser to call. For models without a parser yet, it returns the path to the output JSON along with a message instead.

The PR also updates the documentation for all functions involved.

NB: I accidentally created the branch tidy-output from my branch vignettes rather than main, so it inherited the commits under consideration in #30.


TreePPL Release Notes

Added

  • treepplr 0.4: At the end of a run, tp_run() prints a summary with some runtime information and output directories/files. We can add more to this summary later if needed.
  • treepplr 0.4: A test for tp_run() when using MCMC.
  • treepplr 0.4: Argument wide to tp_parse_smc() and tp_parse_mcmc() to let users decide whether the resulting data frame is in wide (standard in other software) or long (good for plotting) format. Default = TRUE.
  • treepplr 0.4: importFrom("methods", "new") to NAMESPACE to suppress one of the warnings during R CMD check.

Changed

  • treepplr 0.4: Changed the output of tp_run() from a list object to a (humanly readable) tidy data frame.
  • treepplr 0.4: Changed the expected input of tp_parse_smc() and tp_parse_mcmc() from a list object to a character vector containing the path to the JSON output file(s). Before, the parsers only worked on the list previously returned by tp_run(), creating a strict dependency between tp_run() and the parser functions and vice-versa. Now the parser functions can also be used by anyone who ran a TreePPL analysis from the terminal and wants to do the post-processing in R with treepplr.
  • treepplr 0.4: Because the output of tp_run() changed, I redesigned its tests, keeping the same logic as the old ones.
  • treepplr 0.4: tp_run() now returns data frames in wide format by default.
  • treepplr 0.4: tp_mcmc_convergence() and tp_smc_convergence() accept data frames in either long or wide format.

Deprecated

Removed

Fixed

Security

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant