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
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check-wsl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:

- name: Install cmdstan
run: |
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
cmdstanr::check_cmdstan_toolchain()
cmdstanr::install_cmdstan(cores = 2, wsl = TRUE, overwrite = TRUE)
shell: Rscript {0}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:

- name: Install cmdstan
run: |
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
cmdstanr::check_cmdstan_toolchain()
tarball_url <- Sys.getenv("CMDSTAN_TEST_TARBALL_URL")
if (nzchar(tarball_url)) {
cmdstanr::install_cmdstan(
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:

- name: Install cmdstan
run: |
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
cmdstanr::check_cmdstan_toolchain()
cmdstanr::install_cmdstan(cores = 2)
shell: Rscript {0}

Expand Down
17 changes: 11 additions & 6 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
# cmdstanr (development version)

* Informative error when exposing functions using names that are reserved
keywords (@VisruthSK, #1154)
* `save_cmdstan_config` and `save_metric` default to `FALSE` but can be
set to `TRUE` for an entire R session via new global options. (#1159)

* CmdStanModel objects created using `compile_model_methods = TRUE` that are
then saved and reloaded no longer error in model fitting methods. Model methods
are recompiled lazily if needed.
are recompiled lazily if needed. (#1158)

* CmdStan versions older than 2.35.0 are no longer supported.
* Minimum R version increased to 4.0.0.
* Removed legacy Windows toolchain paths for older CmdStan releases.
* `CMDSTANR_USE_MSYS_TOOLCHAIN` is now deprecated and ignored (with a warning).
* CmdStan versions older than 2.35.0 are no longer supported. (#1144)
* Minimum R version increased to 4.0.0. (#1144)
* Removed legacy Windows toolchain paths for older CmdStan releases. (#1144)
* `CMDSTANR_USE_MSYS_TOOLCHAIN` is now deprecated and ignored (with a warning). (#1144)

* Removed deprecated items (replacements in parentheses):
* Removed deprecated items (replacements in parentheses). (#1061)
- `read_sample_csv()` (`read_cmdstan_csv()`)
- `write_stan_tempfile()` (`write_stan_file()`)
- `jacobian_adjustment` argument to `fit$log_prob()` and similar methods (`jacobian` argument)
Expand Down
16 changes: 1 addition & 15 deletions R/args.R
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,6 @@ validate_cmdstan_args <- function(self) {
checkmate::assert_integerish(self$refresh, lower = 0, null.ok = TRUE)
checkmate::assert_integerish(self$sig_figs, lower = 1, upper = 18, null.ok = TRUE)
checkmate::assert_integerish(self$save_cmdstan_config, lower = 0, upper = 1, len = 1, null.ok = TRUE)
if (!is.null(self$sig_figs) && cmdstan_version() < "2.25") {
warning("The 'sig_figs' argument is only supported with cmdstan 2.25+ and will be ignored!", call. = FALSE)
}
if (!is.null(self$refresh)) {
self$refresh <- as.integer(self$refresh)
}
Expand All @@ -710,9 +707,6 @@ validate_cmdstan_args <- function(self) {
validate_init(self$init, num_inits)
validate_seed(self$seed, num_procs)
if (!is.null(self$opencl_ids)) {
if (cmdstan_version() < "2.26") {
stop("Runtime selection of OpenCL devices is only supported with CmdStan version 2.26 or newer.", call. = FALSE)
}
checkmate::assert_vector(self$opencl_ids, len = 2)
}
invisible(TRUE)
Expand Down Expand Up @@ -830,9 +824,6 @@ validate_optimize_args <- function(self) {
choices = c("bfgs", "lbfgs", "newton"))
checkmate::assert_flag(self$jacobian, null.ok = TRUE)
if (!is.null(self$jacobian)) {
if (cmdstan_version() < "2.32") {
warning("The 'jacobian' argument is only supported with cmdstan 2.32+ and will be ignored!", call. = FALSE)
}
self$jacobian <- as.integer(self$jacobian)
}

Expand Down Expand Up @@ -1494,12 +1485,7 @@ validate_seed <- function(seed, num_procs) {
if (is.null(seed)) {
return(invisible(TRUE))
}
if (cmdstan_version() < "2.26") {
lower_seed <- 1
} else {
lower_seed <- 0
}
checkmate::assert_integerish(seed, lower = lower_seed)
checkmate::assert_integerish(seed, lower = 0)
if (length(seed) > 1 && length(seed) != num_procs) {
stop("If 'seed' is specified it must be a single integer or one per chain.",
call. = FALSE)
Expand Down
2 changes: 1 addition & 1 deletion R/cmdstanr-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
#'
"_PACKAGE"

if (getRversion() >= "2.15.1") utils::globalVariables(c("self", "private", "super"))
utils::globalVariables(c("self", "private", "super"))
33 changes: 15 additions & 18 deletions R/cpp_opts.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,24 @@ parse_exe_info_string <- function(ret_stdout) {
# old (current) parser
model_compile_info <- function(exe_file, version) {
info <- NULL
if (version > "2.26.1") {

ret <- run_info_cli(exe_file)
if (ret$status == 0) {
info <- list()
info_raw <- strsplit(strsplit(ret$stdout, "\n")[[1]], "=")
for (key_val in info_raw) {
if (length(key_val) > 1) {
key_val <- trimws(key_val)
val <- key_val[2]
if (!is.na(as.logical(val))) {
val <- as.logical(val)
}
info[[toupper(key_val[1])]] <- val
ret <- run_info_cli(exe_file)
if (ret$status == 0) {
info <- list()
info_raw <- strsplit(strsplit(ret$stdout, "\n")[[1]], "=")
for (key_val in info_raw) {
if (length(key_val) > 1) {
key_val <- trimws(key_val)
val <- key_val[2]
if (!is.na(as.logical(val))) {
val <- as.logical(val)
}
info[[toupper(key_val[1])]] <- val
}
info[["STAN_VERSION"]] <- paste0(info[["STAN_VERSION_MAJOR"]], ".", info[["STAN_VERSION_MINOR"]], ".", info[["STAN_VERSION_PATCH"]])
info[["STAN_VERSION_MAJOR"]] <- NULL
info[["STAN_VERSION_MINOR"]] <- NULL
info[["STAN_VERSION_PATCH"]] <- NULL
}
info[["STAN_VERSION"]] <- paste0(info[["STAN_VERSION_MAJOR"]], ".", info[["STAN_VERSION_MINOR"]], ".", info[["STAN_VERSION_PATCH"]])
info[["STAN_VERSION_MAJOR"]] <- NULL
info[["STAN_VERSION_MINOR"]] <- NULL
info[["STAN_VERSION_PATCH"]] <- NULL
}
info
}
Expand Down
25 changes: 7 additions & 18 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,15 @@
#' The `list` to `array` conversion is intended to make it easier to prepare
#' the data for certain Stan declarations involving arrays:
#'
#' * `vector[J] v[K]` (or equivalently `array[K] vector[J] v ` as of Stan 2.27)
#' can be constructed in \R as a list with `K` elements where each element a
#' vector of length `J`
#' * `matrix[I,J] v[K]` (or equivalently `array[K] matrix[I,J] m ` as of Stan
#' 2.27 ) can be constructed in \R as a list with `K` elements where each element
#' an `IxJ` matrix
#' * `array[K] vector[J] v ` can be constructed in \R as a list with `K`
#' elements where each element a vector of length `J`
#' * `array[K] matrix[I,J] m ` can be constructed in \R as a list with `K`
#' elements where each element an `IxJ` matrix
#'
#' These can also be passed in from \R as arrays instead of lists but the list
#' option is provided for convenience. Unfortunately for arrays with more than
#' one dimension, e.g., `vector[J] v[K,L]` (or equivalently
#' `array[K,L] vector[J] v ` as of Stan 2.27) it is not possible to use an \R
#' list and an array must be used instead. For this example the array in \R
#' one dimension (e.g. `array[K,L] vector[J] v `) it is not possible to use an
#' \R list and an array must be used instead. For this example the array in \R
#' should have dimensions `KxLxJ`.
#'
#' @examples
Expand All @@ -49,7 +46,7 @@
#'
#'
#' # demonstrating list to array conversion
#' # suppose x is declared as `vector[3] x[2]` (or equivalently `array[2] vector[3] x`)
#' # suppose x is declared as `array[2] vector[3] x`
#' # we can use a list of length 2 where each element is a vector of length 3
#' data <- list(x = list(1:3, 4:6))
#' file <- tempfile(fileext = ".json")
Expand Down Expand Up @@ -159,14 +156,6 @@ process_data <- function(data, model_variables = NULL) {
} else if (is.character(data)) {
path <- absolute_path(data)
} else if (is.list(data) && !is.data.frame(data)) {
if (cmdstan_version() < "2.22" && any_zero_dims(data)) {
stop(
"Data includes 0-dimensional data structures. To use this data please ",
"either update your CmdStan installation with install_cmdstan() ",
"or specify data as a file created by rstan::stan_rdump().",
call. = FALSE
)
}
if (!is.null(model_variables)) {
data_variables <- model_variables$data
is_data_supplied <- names(data_variables) %in% names(data)
Expand Down
4 changes: 2 additions & 2 deletions R/fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -1205,8 +1205,8 @@ CmdStanFit$set("public", name = "return_codes", value = return_codes)
#' profiling data if any profiling data was written to the profile CSV files.
#' See [save_profile_files()] to control where the files are saved.
#'
#' Support for profiling Stan programs is available with CmdStan >= 2.26 and
#' requires adding profiling statements to the Stan program.
#' Profiling requires adding profiling statements to the Stan program. See
#' **Examples** for a demonstration.
#'
#' @return A list of data frames with profiling data if the profiling CSV files
#' were created.
Expand Down
18 changes: 10 additions & 8 deletions R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ install_cmdstan <- function(dir = NULL,
.cmdstanr$WSL <- FALSE
}
if (check_toolchain) {
check_cmdstan_toolchain(fix = FALSE, quiet = quiet)
check_cmdstan_toolchain(quiet = quiet)
}
make_local_msg <- NULL
if (!is.null(cmdstan_version(error_on_NA = FALSE))) {
Expand Down Expand Up @@ -336,17 +336,20 @@ cmdstan_make_local <- function(dir = cmdstan_path(),

#' @rdname install_cmdstan
#' @export
#' @param fix For `check_cmdstan_toolchain()`, should CmdStanR attempt to fix
#' any detected toolchain problems? The default is `FALSE`.
#' This argument is currently ignored and retained for compatibility.
#' @param fix As of v1.0 this argument is deprecated and ignored and only
#' retained for compatibility.
#'
check_cmdstan_toolchain <- function(fix = FALSE, quiet = FALSE) {
if (isTRUE(fix)) {
warning("The 'fix' argument is deprecated and will be removed in a future release.",
call. = FALSE)
}
warn_if_ignored_msys_toolchain_env()
if (os_is_windows()) {
if (os_is_wsl()) {
check_wsl_toolchain()
} else {
check_rtools4x_windows_toolchain(fix = fix, quiet = quiet)
check_rtools4x_windows_toolchain(quiet = quiet)
}
} else {
check_unix_make()
Expand Down Expand Up @@ -593,7 +596,7 @@ check_wsl_toolchain <- function() {
}
}

check_rtools4x_windows_toolchain <- function(fix = FALSE, quiet = FALSE) {
check_rtools4x_windows_toolchain <- function(quiet = FALSE) {
rtools_path <- rtools4x_home_path()
rtools_version <- paste0("Rtools", rtools4x_version())
# If RTOOLS4X_HOME is not set (the env. variable gets set on install)
Expand Down Expand Up @@ -697,8 +700,7 @@ check_unix_cpp_compiler <- function() {

cmdstan_arch_suffix <- function(version = NULL) {
os_needs_arch <- os_is_linux() || os_is_wsl()
if ((!is.null(version) && version < "2.26") || !os_needs_arch) {
# pre-CmdStan 2.26, only the x86 tarball was provided
if (!os_needs_arch) {
return(NULL)
}

Expand Down
Loading
Loading