Skip to content

Commit d79ffd8

Browse files
committed
Merge branch 'master' into document-structured-draws-via-draws_of
2 parents 0dbe050 + 4a865bb commit d79ffd8

6 files changed

Lines changed: 19 additions & 12 deletions

File tree

.github/workflows/R-CMD-check.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ jobs:
3131
- {os: ubuntu-20.04, r: 'devel', rtools: ''}
3232
- {os: ubuntu-20.04, r: 'release', rtools: ''}
3333
- {os: ubuntu-20.04, r: 'oldrel', rtools: ''}
34-
- {os: ubuntu-20.04, r: '3.6', rtools: ''}
3534
env:
3635
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
3736
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

tests/testthat/test-fit-mle.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ test_that("time is reported after optimization", {
5252
})
5353

5454
test_that("no error when checking estimates after failure", {
55-
fit <- cmdstanr_example("schools", method = "optimize", seed = 123) # optim ålways fails for this
55+
expect_warning(
56+
fit <- cmdstanr_example("schools", method = "optimize", seed = 123), # optim ålways fails for this
57+
"Fitting finished unexpectedly"
58+
)
5659
expect_error(fit$summary(), "Fitting failed. Unable to retrieve the draws.")
5760
})
5861

tests/testthat/test-fit-shared.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ test_that("return_codes method works properly", {
216216
expect_equal(fits[["generate_quantities"]]$return_codes(), c(0,0,0,0))
217217

218218
# non-zero
219-
non_zero <- testing_fit("schools", method = "optimize", seed = 123)
219+
expect_warning(
220+
non_zero <- testing_fit("schools", method = "optimize", seed = 123),
221+
"Fitting finished unexpectedly"
222+
)
220223
expect_gt(non_zero$return_codes(), 0)
221224
})
222225

tests/testthat/test-model-laplace.R

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ test_that("laplace() runs when all arguments specified validly", {
5454
expect_equal(fit1$metadata()$draws, as.integer(ok_arg_values$draws))
5555
expect_equal(fit1$mode()$metadata()$jacobian, as.integer(ok_arg_values$jacobian))
5656
expect_equal(fit1$mode()$metadata()$init_alpha, ok_arg_values$opt_args$init_alpha)
57-
57+
5858
expect_equal(fit1$mode()$metadata()$tol_obj, ok_arg_values$opt_args$tol_obj, tolerance = 0)
5959

6060
# leaving all at default (except 'data')
@@ -121,11 +121,13 @@ test_that("laplace() errors with bad combinations of arguments", {
121121
test_that("laplace() errors if optimize() fails", {
122122
mod_schools <- testing_model("schools")
123123
expect_error(
124-
expect_message(
125-
mod_schools$laplace(data = testing_data("schools"), refresh = 0),
126-
"Line search failed to achieve a sufficient decrease"
124+
expect_warning(
125+
expect_message(
126+
mod_schools$laplace(data = testing_data("schools"), refresh = 0),
127+
"Line search failed to achieve a sufficient decrease"
128+
),
129+
"Fitting finished unexpectedly"
127130
),
128131
"Optimization failed"
129132
)
130-
131133
})

tests/testthat/test-model-methods.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ test_that("Variable skeleton returns correct dimensions for matrices", {
300300
N <- 4
301301
K <- 3
302302
fit <- mod$sample(data = list(N = N, K = K), chains = 1,
303-
iter_warmup = 1, iter_sampling = 1)
303+
iter_warmup = 1, iter_sampling = 5)
304304

305305
target_skeleton <- list(
306306
x_real = array(0, dim = 1),

tests/testthat/test-model-sample.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ test_that("print statements in transformed data work", {
246246
}'
247247
))
248248

249-
out <- capture.output(fit <- mod$sample(iter_warmup = 1, iter_sampling = 1, chains = 1))
249+
out <- capture.output(fit <- mod$sample(iter_warmup = 1, iter_sampling = 5, chains = 1))
250250
expect_true(any(grepl("*N = 2*", out)))
251251
})
252252

@@ -276,7 +276,7 @@ test_that("seed works for multi chain sampling", {
276276
f <- write_stan_file(m, basename = "rngs.stan")
277277
mod <- cmdstan_model(f)
278278
utils::capture.output(
279-
fit_sample <- mod$sample(chains = 2, iter_sampling = 1, iter_warmup = 100, seed = 2)
279+
fit_sample <- mod$sample(chains = 2, iter_sampling = 5, iter_warmup = 100, seed = 2)
280280
)
281281
chain_tdata_1 <- posterior::subset_draws(fit_sample$draws("tdata"), chain = 1)
282282
chain_tdata_2 <- posterior::subset_draws(fit_sample$draws("tdata"), chain = 2)
@@ -286,7 +286,7 @@ test_that("seed works for multi chain sampling", {
286286
expect_false(all(chain_tdata_1 == chain_tdata_2))
287287

288288
utils::capture.output(
289-
fit_sample <- mod$sample(chains = 2, iter_sampling = 1, iter_warmup = 100,
289+
fit_sample <- mod$sample(chains = 2, iter_sampling = 5, iter_warmup = 100,
290290
seed = c(1, 2))
291291
)
292292
chain_tdata_1 <- posterior::subset_draws(fit_sample$draws("tdata"), chain = 1)

0 commit comments

Comments
 (0)