From eb3454634bae7a3d93c60d56d7efd790cc6d6032 Mon Sep 17 00:00:00 2001 From: Seth Axen Date: Mon, 14 Sep 2026 14:48:44 +0200 Subject: [PATCH 1/2] Make r2_score doctest robust to rounding --- ext/InferenceObjectsPosteriorStatsExt/r2_score.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/InferenceObjectsPosteriorStatsExt/r2_score.jl b/ext/InferenceObjectsPosteriorStatsExt/r2_score.jl index 5360fad3..f169473d 100644 --- a/ext/InferenceObjectsPosteriorStatsExt/r2_score.jl +++ b/ext/InferenceObjectsPosteriorStatsExt/r2_score.jl @@ -19,8 +19,8 @@ julia> using ArviZExampleData, PosteriorStats julia> idata = load_example_data("anes"); -julia> r2_score(idata) -(r2 = 0.4944850210319484, eti = 0.46184359652436546 .. 0.528018251711097) +julia> round(r2_score(idata).r2; digits=3) +0.494 ``` """ function PosteriorStats.r2_score( From 3904a4133b1bd059f6cd36ffe578bbbc39c1fac3 Mon Sep 17 00:00:00 2001 From: Seth Axen Date: Mon, 14 Sep 2026 15:06:25 +0200 Subject: [PATCH 2/2] Use a doctest filter for r2 output --- ext/InferenceObjectsPosteriorStatsExt/r2_score.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/InferenceObjectsPosteriorStatsExt/r2_score.jl b/ext/InferenceObjectsPosteriorStatsExt/r2_score.jl index f169473d..e9e49015 100644 --- a/ext/InferenceObjectsPosteriorStatsExt/r2_score.jl +++ b/ext/InferenceObjectsPosteriorStatsExt/r2_score.jl @@ -14,13 +14,13 @@ Compute ``R²`` from `idata`, automatically formatting the predictions to the co # Examples -```jldoctest +```jldoctest; filter = r"(r2 = \\d\\.\\d{3})\\d+" => s"\\1" julia> using ArviZExampleData, PosteriorStats julia> idata = load_example_data("anes"); -julia> round(r2_score(idata).r2; digits=3) -0.494 +julia> r2_score(idata) +(r2 = 0.4944850210319484, eti = 0.46184359652436546 .. 0.528018251711097) ``` """ function PosteriorStats.r2_score(