Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -2095,12 +2095,16 @@ generate_quantities <- function(fitted_params,
sig_figs = NULL,
parallel_chains = getOption("mc.cores", 1),
threads_per_chain = NULL,
opencl_ids = NULL) {
opencl_ids = NULL,
show_messages = TRUE,
show_exceptions = TRUE) {
fitted_params_files <- process_fitted_params(fitted_params)
procs <- CmdStanGQProcs$new(
num_procs = length(fitted_params_files),
parallel_procs = checkmate::assert_integerish(parallel_chains, lower = 1, null.ok = TRUE),
threads_per_proc = assert_valid_threads(threads_per_chain, self$cpp_options(), multiple_chains = TRUE)
threads_per_proc = assert_valid_threads(threads_per_chain, self$cpp_options(), multiple_chains = TRUE),
show_stderr_messages = show_exceptions,
show_stdout_messages = show_messages
)
model_variables <- NULL
if (is_variables_method_supported(self)) {
Expand Down
17 changes: 16 additions & 1 deletion man/model-method-generate-quantities.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions tests/testthat/test-model-generate_quantities.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,14 @@ test_that("generate_quantities() warns if threads specified but not enabled", {
"'threads_per_chain' will have no effect"
)
})

test_that("no output with show_messages = FALSE", {
output <- utils::capture.output(
fit_gq <- mod_gq$generate_quantities(
fitted_params = fit,
data = data_list,
show_messages = FALSE
)
)
expect_equal(length(output), 0)
})
7 changes: 7 additions & 0 deletions tests/testthat/test-model-pathfinder.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,10 @@ test_that("no error when checking estimates after failure", {
expect_silent(fit$summary()) # no error
})

test_that("no output with show_messages = FALSE", {
output <- utils::capture.output(
fit <- mod$pathfinder(data = data_list, show_messages = FALSE, seed = 123)
)
expect_equal(length(output), 0)
})