Skip to content

Commit 9bd9ff0

Browse files
author
Florence Bockting
committed
tests: use expect_snapshot to check table output
1 parent 5145c66 commit 9bd9ff0

2 files changed

Lines changed: 55 additions & 4 deletions

File tree

tests/testthat/_snaps/print_plot.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,54 @@
22

33
WAoAAAACAAQFAAACAwAAAAAOAAAAAT+2J8YDcP5s
44

5+
# print.loo supports kfold with pareto-k diagnostics - calibrated
6+
7+
Code
8+
print(kfold1)
9+
Output
10+
11+
Based on 10-fold cross-validation.
12+
13+
Estimate SE
14+
elpd_kfold -284.7 10.0
15+
p_kfold 2.4 0.6
16+
kfoldic 569.3 20.1
17+
------
18+
19+
All Pareto k estimates are good (k < 0.7).
20+
See help('pareto-k-diagnostic') for details.
21+
22+
# print.loo supports kfold with pareto-k diagnostics - miscalibrated
23+
24+
Code
25+
print(kfold1)
26+
Output
27+
28+
Based on 10-fold cross-validation.
29+
30+
Estimate SE
31+
elpd_kfold -5521.0 713.1
32+
p_kfold 318.5 97.9
33+
kfoldic 11042.0 1426.3
34+
------
35+
36+
Pareto k diagnostic values:
37+
Count Pct. Min. ESS
38+
(-Inf, 0.7] (good) 249 95.0% <NA>
39+
(0.7, 1] (bad) 6 2.3% <NA>
40+
(1, Inf) (very bad) 7 2.7% <NA>
41+
See help('pareto-k-diagnostic') for details.
42+
43+
# print.loo supports kfold without pareto-k diagnostics
44+
45+
Code
46+
print(kfold1)
47+
Output
48+
49+
Based on 10-fold cross-validation.
50+
51+
Estimate SE
52+
elpd_kfold -5521.0 713.1
53+
p_kfold 318.5 97.9
54+
kfoldic 11042.0 1426.3
55+

tests/testthat/test_print_plot.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,18 +191,18 @@ test_that("mcse_loo errors if not psis_loo object", {
191191
test_that("print.loo supports kfold with pareto-k diagnostics - calibrated", {
192192
kfold1 <- readRDS("data-for-tests/kfold-calibrated.Rds")
193193

194-
expect_output(print(kfold1), "All Pareto k estimates are good")
194+
expect_snapshot(print(kfold1))
195195
})
196196

197197
test_that("print.loo supports kfold with pareto-k diagnostics - miscalibrated", {
198198
kfold1 <- readRDS("data-for-tests/kfold-miscalibrated.Rds")
199-
200-
expect_output(print(kfold1), "Pareto k diagnostic values:")
199+
200+
expect_snapshot(print(kfold1))
201201
})
202202

203203
test_that("print.loo supports kfold without pareto-k diagnostics", {
204204
kfold1 <- readRDS("data-for-tests/kfold-miscalibrated.Rds")
205205
kfold1$diagnostics <- NULL
206206

207-
expect_output(print(kfold1), "Based on 10-fold cross-validation.")
207+
expect_snapshot(print(kfold1))
208208
})

0 commit comments

Comments
 (0)