Skip to content

Commit

Permalink
add options to silence compiler messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasjclark committed May 28, 2024
1 parent ada755f commit 18da5af
Show file tree
Hide file tree
Showing 12 changed files with 1,281 additions and 1,052 deletions.
1,107 changes: 1,107 additions & 0 deletions R/backends.R

Large diffs are not rendered by default.

304 changes: 50 additions & 254 deletions R/mvgam.R

Large diffs are not rendered by default.

855 changes: 63 additions & 792 deletions R/stan_utils.R

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions R/validations.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,48 @@ validate_series_time = function(data, name = 'data',
return(data)
}

#'@noRd
as_one_logical = function (x, allow_na = FALSE) {
s <- substitute(x)
x <- as.logical(x)
if (length(x) != 1L || anyNA(x) && !allow_na) {
s <- deparse0(s, max_char = 100L)
stop("Cannot coerce '", s, "' to a single logical value.",
call. = FALSE)
}
x
}

#'@noRd
as_one_integer <- function(x, allow_na = FALSE) {
s <- substitute(x)
x <- suppressWarnings(as.integer(x))
if (length(x) != 1L || anyNA(x) && !allow_na) {
s <- deparse0(s, max_char = 100L)
stop("Cannot coerce '", s, "' to a single integer value.",
call. = FALSE)
}
x
}

#'@noRd
deparse0 = function (x, max_char = NULL, ...) {
out <- collapse(deparse(x, ...))
if (isTRUE(max_char > 0)) {
out <- substr(out, 1L, max_char)
}
out
}

#'@noRd
validate_silent <- function(silent) {
silent <- as_one_integer(silent)
if (silent < 0 || silent > 2) {
stop2("'silent' must be between 0 and 2.")
}
silent
}

#'@importFrom rlang warn
#'@noRd
validate_family = function(family, use_stan = TRUE){
Expand Down
11 changes: 9 additions & 2 deletions man/mvgam.Rd

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

2 changes: 2 additions & 0 deletions man/mvgam_marginaleffects.Rd

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

Binary file modified src/RcppExports.o
Binary file not shown.
Binary file modified src/mvgam.dll
Binary file not shown.
Binary file modified src/trend_funs.o
Binary file not shown.
Binary file modified tests/testthat/Rplots.pdf
Binary file not shown.
9 changes: 6 additions & 3 deletions tests/testthat/test-binomial.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ test_that("binomial() post-processing works", {
data = dat_train,
burnin = 500,
samples = 200,
chains = 2))
chains = 2,
silent = 2))
expect_no_error(capture_output(summary(mod)))
expect_no_error(capture_output(code(mod)))
expect_no_error(capture_output(print(mod)))
Expand Down Expand Up @@ -158,7 +159,8 @@ test_that("binomial() post-processing works", {
newdata = dat_test,
burnin = 200,
samples = 200,
chains = 2))
chains = 2,
silent = 2))
fc <- forecast(mod)
expect_true(inherits(fc, 'mvgam_forecast'))
expect_no_error(plot_mvgam_uncertainty(mod))
Expand Down Expand Up @@ -281,7 +283,8 @@ test_that("bernoulli() post-processing works", {
data = dat_train,
burnin = 200,
samples = 200,
chains = 2))
chains = 2,
silent = 2))

expect_no_error(capture_output(summary(mod)))
expect_no_error(capture_output(print(mod)))
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-nmixture.R
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ test_that("nmix() post-processing works", {
prior(normal(1, 1.5), class = Intercept_trend)),
samples = 300,
residuals = FALSE,
chains = 2))
chains = 2,
silent = 2))

expect_no_error(capture_output(summary(mod)))
expect_no_error(capture_output(print(mod)))
Expand Down

0 comments on commit 18da5af

Please sign in to comment.