Distributions.jl icon indicating copy to clipboard operation
Distributions.jl copied to clipboard

Fix R test references and make them reproducible

Open devmotion opened this issue 2 months ago • 1 comments

When working on adding a new distribution, I realized (once again) that the R test references can't be re-generated currently since running Rscript gendref.R errors:

  • The LindleyR package is not available anymore
  • For distr = StudentizedRange(...) since the function distr$pdf is undefined
  • truncated(Normal(...), ...) is not a valid reference name as it can't be mapped to a reference distribution

Moreover, after commenting out these three reference distribution types rerunning Rscript gendref.R changes reference values for most distributions.


This PR tries to fix the setup of the R reference tests:

  • Use renv for a reproducible package environment
  • Add a GHA that updates the R environment and reference values (scheduled and manually)
  • Replace LindleyR with new.dist
  • Use explicit package::function syntax instead of relying on library(package) in other source files
  • Calculate (log)pdf reference values of StudentizedRange by finite differencing of (log)cdf
  • Allow manual specification of distr$dtype and distr$expr (to support truncated(...) properly)
  • Simplify matrix-variate data generation by using StanHeaders instead of rstan
  • Improve definition of reference distributions for alternative Julia distribution types (e.g. Erlang and NormalCanon)
  • Update test/ref/readme.md
  • Update reference values by running Rscript gendref.R

devmotion avatar Oct 18 '25 19:10 devmotion

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 86.29%. Comparing base (bbdd4f1) to head (9d75f78).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2007      +/-   ##
==========================================
- Coverage   86.35%   86.29%   -0.07%     
==========================================
  Files         146      146              
  Lines        8782     8782              
==========================================
- Hits         7584     7578       -6     
- Misses       1198     1204       +6     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar Oct 18 '25 19:10 codecov-commenter