Skip to content

Commit

Permalink
updates in response to lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
sbfnk committed Feb 2, 2024
1 parent 0d54c93 commit 7f6ac55
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/workflows/lint-only-changed-files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
with:
dependencies: NA
extra-packages: |
stan-dev/cmdstanr
any::gh
any::lintr
any::purrr
Expand Down
8 changes: 4 additions & 4 deletions R/estimate_infections.R
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ init_cumulative_fit <- function(args, samples = 50, warmup = 50,
open_progress = FALSE,
show_messages = FALSE
),
data = args$data, init = args$init,
data = args$data, init = args$init
)
# change observations to be cumulative in order to protect against noise and
# give an approximate fit (though for Rt constrained to be > 1)
Expand Down Expand Up @@ -450,10 +450,10 @@ fit_model_with_nuts <- function(args, future = FALSE, max_execution_time = Inf,
)
}

if (!inherits(fit, c("stanfit", "CmdStanMCMC"))) {
return(NULL)
} else {
if (inherits(fit, c("stanfit", "CmdStanMCMC"))) {
return(fit)
} else {
return(NULL)
}
}

Expand Down
2 changes: 1 addition & 1 deletion R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ extract_samples <- function(stan_fit, pars = NULL, include = TRUE) {
)
df <- df[, new_draw := permutation[.draw]]
setkey(df, new_draw)
max_indices <- strsplit(tail(df$index, 1), split = ",")[[1]]
max_indices <- strsplit(tail(df$index, 1), split = ",", fixed = TRUE)[[1]]
if (any(grepl("[^0-9]", max_indices))) {
max_indices <- 1
} else {
Expand Down
12 changes: 5 additions & 7 deletions R/opts.R
Original file line number Diff line number Diff line change
Expand Up @@ -791,13 +791,11 @@ stan_opts <- function(object = NULL,
...) {
method <- arg_match(method, values = c("sampling", "vb"))
backend <- arg_match(backend, values = c("rstan", "cmdstanr"))
if (backend == "cmdstanr") {
if (!requireNamespace("cmdstanr", quietly = TRUE)) {
stop(paste0(
"The `cmdstanr` package needs to be installed for using the ",
"\"cmdstanr\" backend."
))
}
if (backend == "cmdstanr" && !requireNamespace("cmdstanr", quietly = TRUE)) {
stop(
"The `cmdstanr` package needs to be installed for using the ",
"\"cmdstanr\" backend."
)
}
opts <- list()
if (!is.null(object) && !missing(backend)) {
Expand Down
2 changes: 1 addition & 1 deletion R/stan.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ package_model <- function(model = "estimate_infections",
)
if (verbose) {
message(sprintf("Using model %s.", model))
message(sprintf("include is %s.", paste(include, collapse = ", ")))
message(sprintf("include is %s.", toString(include)))
}

monitor <- suppressMessages
Expand Down

0 comments on commit 7f6ac55

Please sign in to comment.