Skip to content

Commit b2fd544

Browse files
committed
use skip_on_cran for some of test_loo_subsampling
need to get under CRAN timing limit
1 parent bed437f commit b2fd544

File tree

4 files changed

+21
-41
lines changed

4 files changed

+21
-41
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: loo
22
Type: Package
33
Title: Efficient Leave-One-Out Cross-Validation and WAIC for Bayesian Models
44
Version: 2.2.0
5-
Date: 2019-12-16
5+
Date: 2019-12-18
66
Authors@R: c(person("Aki", "Vehtari", email = "[email protected]", role = c("aut")),
77
person("Jonah", "Gabry", email = "[email protected]", role = c("cre", "aut")),
88
person("Mans", "Magnusson", role = c("aut")),

tests/testthat/test_loo_approximate_posterior.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ for(j in 1:N){
4949

5050

5151
test_that("loo_approximate_posterior.array works as loo_approximate_posterior.matrix", {
52-
skip_if_not_installed("checkmate")
5352

5453
# Create array with two "chains"
5554
log_p_mat <- matrix(log_p, nrow = (S/2), ncol = 2)
@@ -86,7 +85,7 @@ test_that("loo_approximate_posterior.array works as loo_approximate_posterior.ma
8685
})
8786

8887
test_that("loo_approximate_posterior.function works as loo_approximate_posterior.matrix", {
89-
skip_if_not_installed("checkmate")
88+
9089

9190
# Compute aploo
9291
expect_silent(aploo1 <- loo_approximate_posterior.matrix(x = ll, log_p = log_p, log_g = log_g))

tests/testthat/test_loo_subsampling.R

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ options(mc.cores = 1)
44
context("loo_subsampling")
55

66
test_that("overall loo_subampling works as expected (compared with loo) for diff_est", {
7-
skip_if_not_installed("checkmate")
8-
97
set.seed(123)
108
N <- 1000; K <- 10; S <- 1000; a0 <- 3; b0 <- 2
119
p <- 0.7
@@ -91,8 +89,6 @@ test_that("overall loo_subampling works as expected (compared with loo) for diff
9189
})
9290

9391
test_that("loo with subsampling of all observations works as ordinary loo.", {
94-
skip_if_not_installed("checkmate")
95-
9692
set.seed(123)
9793
N <- 1000; K <- 10; S <- 1000; a0 <- 3; b0 <- 2
9894
p <- 0.7
@@ -122,8 +118,6 @@ test_that("loo with subsampling of all observations works as ordinary loo.", {
122118
})
123119

124120
test_that("overall loo_subsample works with diff_srs as expected (compared with loo)", {
125-
skip_if_not_installed("checkmate")
126-
127121
set.seed(123)
128122
N <- 1000; K <- 10; S <- 1000; a0 <- 3; b0 <- 2
129123
p <- 0.7
@@ -143,8 +137,6 @@ test_that("overall loo_subsample works with diff_srs as expected (compared with
143137
})
144138

145139
test_that("Test the srs estimator with 'none' approximation", {
146-
skip_if_not_installed("checkmate")
147-
148140
set.seed(123)
149141
N <- 1000; K <- 10; S <- 1000; a0 <- 3; b0 <- 2
150142
p <- 0.7
@@ -186,8 +178,6 @@ test_that("Test the srs estimator with 'none' approximation", {
186178
})
187179

188180
test_that("Test the Hansen-Hurwitz estimator", {
189-
skip_if_not_installed("checkmate")
190-
191181
set.seed(123)
192182
N <- 1000; K <- 10; S <- 1000; a0 <- 3; b0 <- 2
193183
p <- 0.7
@@ -245,7 +235,7 @@ test_that("Test the Hansen-Hurwitz estimator", {
245235

246236

247237
test_that("update.psis_loo_ss works as expected (compared with loo)", {
248-
skip_if_not_installed("checkmate")
238+
249239

250240
set.seed(123)
251241
N <- 1000; K <- 10; S <- 1000; a0 <- 3; b0 <- 2
@@ -344,7 +334,7 @@ test_that("update.psis_loo_ss works as expected (compared with loo)", {
344334
context("loo_subsampling_approximations")
345335

346336
test_that("elpd_loo_approximation works as expected", {
347-
skip_if_not_installed("checkmate")
337+
348338

349339
set.seed(123)
350340
N <- 10; K <- 10; S <- 1000; a0 <- 3; b0 <- 2
@@ -396,7 +386,7 @@ test_that("elpd_loo_approximation works as expected", {
396386

397387

398388
test_that("Test loo_approximation_draws", {
399-
skip_if_not_installed("checkmate")
389+
400390

401391
set.seed(123)
402392
N <- 1000; K <- 10; S <- 1000; a0 <- 3; b0 <- 2
@@ -432,7 +422,7 @@ test_that("Test loo_approximation_draws", {
432422

433423

434424
test_that("waic using delta method and gradient", {
435-
skip_if_not_installed("checkmate")
425+
436426

437427
if (FALSE){
438428
# Code to generate testdata - saved and loaded to avoid dependency of mvtnorm
@@ -488,7 +478,7 @@ test_that("waic using delta method and gradient", {
488478
})
489479

490480
test_that("waic using delta 2nd order method", {
491-
skip_if_not_installed("checkmate")
481+
492482

493483
if (FALSE){
494484
# Code to generate testdata - saved and loaded to avoid dependency of MCMCPack
@@ -575,7 +565,7 @@ test_that("waic using delta 2nd order method", {
575565
context("loo_subsampling_estimation")
576566

577567
test_that("whhest works as expected", {
578-
skip_if_not_installed("checkmate")
568+
579569

580570
N <- 100
581571
m <- 10
@@ -636,7 +626,7 @@ test_that("whhest works as expected", {
636626

637627

638628
test_that("srs_diff_est works as expected", {
639-
skip_if_not_installed("checkmate")
629+
640630

641631
set.seed(1234)
642632
N <- 1000
@@ -672,7 +662,7 @@ test_that("srs_diff_est works as expected", {
672662
})
673663

674664
test_that("srs_est works as expected", {
675-
skip_if_not_installed("checkmate")
665+
676666

677667
set.seed(1234)
678668
# Cochran 1976 example Table 2.2
@@ -725,7 +715,8 @@ test_that("srs_est works as expected", {
725715
context("loo_subsampling cases")
726716

727717
test_that("Test loo_subsampling and loo_approx with radon data", {
728-
skip_if_not_installed("checkmate")
718+
skip_on_cran() # avoid going over time limit for tests
719+
729720
load(test_path("test_radon_laplace_loo.rda"))
730721
# Rename to spot variable leaking errors
731722
llfun_test <- llfun
@@ -833,13 +824,14 @@ test_that("Test loo_subsampling and loo_approx with radon data", {
833824

834825

835826
test_that("Test the vignette", {
836-
skip_if_not_installed("checkmate")
827+
skip_on_cran()
828+
837829

838830
# NOTE
839831
# If any of these test fails, the vignette probably needs to be updated
840832

841-
if (FALSE){
842-
# Generate vignett test case
833+
if (FALSE) {
834+
# Generate vignette test case
843835
library("rstan")
844836
stan_code <- "
845837
data {
@@ -986,7 +978,7 @@ test_that("Test the vignette", {
986978
context("loo_compare_subsample")
987979

988980
test_that("loo_compare_subsample", {
989-
skip_if_not_installed("checkmate")
981+
skip_on_cran() # to get under cran check time limit
990982

991983
set.seed(123)
992984
N <- 1000
@@ -1067,9 +1059,10 @@ test_that("loo_compare_subsample", {
10671059

10681060
})
10691061

1062+
context("subsample with tis, sis")
10701063

10711064
test_that("Test 'tis' and 'sis'", {
1072-
skip_if_not_installed("checkmate")
1065+
skip_on_cran()
10731066

10741067
set.seed(123)
10751068
N <- 1000; K <- 10; S <- 1000; a0 <- 3; b0 <- 2
@@ -1160,6 +1153,3 @@ test_that("Test 'tis' and 'sis'", {
11601153
expect_gt(loo_ss_sis_S10$estimates["elpd_loo", "Estimate"] + SEs*loo_ss_sis_S10$estimates["elpd_loo", "subsampling SE"], loo_ss_full$estimates["elpd_loo", "Estimate"])
11611154
expect_lt(loo_ss_sis_S10$estimates["elpd_loo", "Estimate"] - SEs*loo_ss_sis_S10$estimates["elpd_loo", "subsampling SE"], loo_ss_full$estimates["elpd_loo", "Estimate"])
11621155
})
1163-
1164-
1165-

tests/testthat/test_psis_approximate_posterior.R

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ context("psis_approximate_posterior")
55
load(test_path("test_data_psis_approximate_posterior.rda"))
66

77
test_that("Laplace approximation, independent posterior", {
8-
skip_if_not_installed("checkmate")
98
log_p <- test_data_psis_approximate_posterior$laplace_independent$log_p
109
log_g <- test_data_psis_approximate_posterior$laplace_independent$log_q
1110
ll <- test_data_psis_approximate_posterior$laplace_independent$log_liks
@@ -26,7 +25,6 @@ test_that("Laplace approximation, independent posterior", {
2625

2726

2827
test_that("Laplace approximation, correlated posterior", {
29-
skip_if_not_installed("checkmate")
3028
log_p <- test_data_psis_approximate_posterior$laplace_correlated$log_p
3129
log_g <- test_data_psis_approximate_posterior$laplace_correlated$log_q
3230
ll <- test_data_psis_approximate_posterior$laplace_correlated$log_liks
@@ -46,7 +44,6 @@ test_that("Laplace approximation, correlated posterior", {
4644
})
4745

4846
test_that("Laplace approximation, normal model", {
49-
skip_if_not_installed("checkmate")
5047
log_p <- test_data_psis_approximate_posterior$laplace_normal$log_p
5148
log_g <- test_data_psis_approximate_posterior$laplace_normal$log_q
5249
ll <- test_data_psis_approximate_posterior$laplace_normal$log_liks
@@ -68,7 +65,6 @@ test_that("Laplace approximation, normal model", {
6865

6966

7067
test_that("ADVI fullrank approximation, independent posterior", {
71-
skip_if_not_installed("checkmate")
7268
log_p <- test_data_psis_approximate_posterior$fullrank_independent$log_p
7369
log_g <- test_data_psis_approximate_posterior$fullrank_independent$log_q
7470
ll <- test_data_psis_approximate_posterior$fullrank_independent$log_liks
@@ -89,7 +85,6 @@ test_that("ADVI fullrank approximation, independent posterior", {
8985

9086

9187
test_that("ADVI fullrank approximation, correlated posterior", {
92-
skip_if_not_installed("checkmate")
9388
log_p <- test_data_psis_approximate_posterior$fullrank_correlated$log_p
9489
log_g <- test_data_psis_approximate_posterior$fullrank_correlated$log_q
9590
ll <- test_data_psis_approximate_posterior$fullrank_correlated$log_liks
@@ -109,7 +104,6 @@ test_that("ADVI fullrank approximation, correlated posterior", {
109104
})
110105

111106
test_that("ADVI fullrank approximation, correlated posterior", {
112-
skip_if_not_installed("checkmate")
113107
log_p <- test_data_psis_approximate_posterior$fullrank_normal$log_p
114108
log_g <- test_data_psis_approximate_posterior$fullrank_normal$log_q
115109
ll <- test_data_psis_approximate_posterior$fullrank_normal$log_liks
@@ -130,7 +124,6 @@ test_that("ADVI fullrank approximation, correlated posterior", {
130124

131125

132126
test_that("ADVI meanfield approximation, independent posterior", {
133-
skip_if_not_installed("checkmate")
134127
log_p <- test_data_psis_approximate_posterior$meanfield_independent$log_p
135128
log_g <- test_data_psis_approximate_posterior$meanfield_independent$log_q
136129
ll <- test_data_psis_approximate_posterior$meanfield_independent$log_liks
@@ -151,7 +144,6 @@ test_that("ADVI meanfield approximation, independent posterior", {
151144

152145

153146
test_that("ADVI meanfield approximation, correlated posterior", {
154-
skip_if_not_installed("checkmate")
155147
log_p <- test_data_psis_approximate_posterior$meanfield_correlated$log_p
156148
log_g <- test_data_psis_approximate_posterior$meanfield_correlated$log_q
157149
ll <- test_data_psis_approximate_posterior$meanfield_correlated$log_liks
@@ -172,7 +164,6 @@ test_that("ADVI meanfield approximation, correlated posterior", {
172164
})
173165

174166
test_that("ADVI meanfield approximation, normal model", {
175-
skip_if_not_installed("checkmate")
176167
log_p <- test_data_psis_approximate_posterior$meanfield_normal$log_p
177168
log_g <- test_data_psis_approximate_posterior$meanfield_normal$log_q
178169
ll <- test_data_psis_approximate_posterior$meanfield_normal$log_liks
@@ -193,7 +184,7 @@ test_that("ADVI meanfield approximation, normal model", {
193184

194185

195186
test_that("ADVI meanfield approximation, normal model", {
196-
skip_if_not_installed("checkmate")
187+
197188
log_p <- test_data_psis_approximate_posterior$meanfield_normal$log_p
198189
log_g <- test_data_psis_approximate_posterior$meanfield_normal$log_q
199190
ll <- test_data_psis_approximate_posterior$meanfield_normal$log_liks
@@ -214,7 +205,7 @@ test_that("ADVI meanfield approximation, normal model", {
214205

215206

216207
test_that("Deprecation of log_q argument", {
217-
skip_if_not_installed("checkmate")
208+
218209
log_p <- test_data_psis_approximate_posterior$laplace_independent$log_p
219210
log_g <- test_data_psis_approximate_posterior$laplace_independent$log_q
220211
ll <- test_data_psis_approximate_posterior$laplace_independent$log_liks

0 commit comments

Comments
 (0)