From 1e3e96a52382ca7b9b04f99e09eaecc76e9df8e7 Mon Sep 17 00:00:00 2001 From: Seth Axen Date: Sat, 23 Dec 2023 19:51:34 -0800 Subject: [PATCH] Make doctest reproducible --- docs/Project.toml | 2 ++ src/stats.jl | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index 52ca0f6a..506ee3e4 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -7,6 +7,7 @@ Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004" MCMCChains = "c7f686f2-ff18-58e9-bc7b-31028e88f75d" MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d" MLJDecisionTreeInterface = "c6f25543-311c-4c74-83dc-3ea6d1015661" +StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd" [compat] @@ -18,5 +19,6 @@ Gadfly = "1.3.4" MCMCChains = "7" MLJBase = "0.19, 0.20, 0.21, 1" MLJDecisionTreeInterface = "0.3, 0.4" +StableRNGs = "1" StatsPlots = "0.14, 0.15" julia = "1.7" diff --git a/src/stats.jl b/src/stats.jl index 41a814dd..bd5834b5 100644 --- a/src/stats.jl +++ b/src/stats.jl @@ -215,16 +215,18 @@ Note that this will return a single interval and will not return multiple interv # Examples -```jldoctest; setup = :(using Random; Random.seed!(582)) -julia> val = rand(500, 2, 3); +```jldoctest +julia> using StableRNGs; rng = StableRNG(42); + +julia> val = rand(rng, 500, 2, 3); julia> chn = Chains(val, [:a, :b]); julia> hdi(chn) HDI - lower upper - a 0.0749 0.999 - b 0.00531 0.940 + lower upper + a 0.0630 0.994 + b 0.0404 0.968 ``` """ function PosteriorStats.hdi(chn::Chains; prob::Real=0.94, kwargs...)