diff --git a/NEWS.md b/NEWS.md index 04e80af73..ec8ce911a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -258,7 +258,7 @@ wrong once `set_cmdstan_path()` had selected a different one. (#1261) ## Removed and deprecated * Minimum R version increased to 4.0.0. (#1144) -* CmdStan versions older than 2.35.0 are no longer supported. To use an older +* CmdStan versions older than 2.37.0 are no longer supported. To use an older CmdStan version install an older CmdStanR release from GitHub. (#1144) * The `CMDSTANR_NO_VER_CHECK` R option and environment variable are deprecated as of CmdStanR 1.0.0; use the lowercase `cmdstanr_no_ver_check` forms instead. diff --git a/R/cmdstanr-package.R b/R/cmdstanr-package.R index 1cedfb779..2bd3d6732 100644 --- a/R/cmdstanr-package.R +++ b/R/cmdstanr-package.R @@ -21,7 +21,7 @@ #' @includeRmd vignettes/children/comparison-with-rstan.md #' #' @section Getting started: CmdStanR requires a working version of CmdStan >= -#' 2.35. If you already have CmdStan installed see [cmdstan_model()] to get +#' 2.37. If you already have CmdStan installed see [cmdstan_model()] to get #' started, otherwise see [install_cmdstan()] to install CmdStan. The vignette #' [_Getting started with CmdStanR_](https://mc-stan.org/cmdstanr/articles/cmdstanr.html) #' demonstrates the basic functionality of the package. diff --git a/R/install.R b/R/install.R index 62d1e46d6..eb324beec 100644 --- a/R/install.R +++ b/R/install.R @@ -27,7 +27,7 @@ #' C++ toolchain. It is called internally by `install_cmdstan()` but can also #' be called directly by the user. #' -#' **CmdStan versions older than 2.35.0 are no longer supported.** If you need +#' **CmdStan versions older than 2.37.0 are no longer supported.** If you need #' to work with an older CmdStan version we recommend installing an older #' CmdStanR release from GitHub. #' @@ -60,11 +60,11 @@ #' @param release_url (string) The URL for the specific CmdStan release or #' release candidate to install. See . #' The URL should point to the tarball (`.tar.gz` file) itself, e.g., -#' `release_url="https://github.com/stan-dev/cmdstan/releases/download/v2.35.0/cmdstan-2.35.0.tar.gz"`. +#' `release_url="https://github.com/stan-dev/cmdstan/releases/download/v2.37.0/cmdstan-2.37.0.tar.gz"`. #' If both `version` and `release_url` are specified then `version` will be used. #' @param release_file (string) A file path to a CmdStan release tar.gz file #' downloaded from the releases page: . -#' For example: `release_file="./cmdstan-2.35.0.tar.gz"`. If `release_file` is +#' For example: `release_file="./cmdstan-2.37.0.tar.gz"`. If `release_file` is #' specified then both `release_url` and `version` will be ignored. #' @param cpp_options (list) Any makefile flags/variables to be written to #' the `make/local` file. For example, `list("CXX" = "clang++")` will force diff --git a/R/model.R b/R/model.R index 4d05830fc..ccf9e8f46 100644 --- a/R/model.R +++ b/R/model.R @@ -1021,11 +1021,6 @@ sample <- function(data = NULL, save_cmdstan_config = getOption("cmdstanr_save_config", FALSE)) { private$assert_current() - if (cmdstan_version_compare(self$cmdstan_version(), "2.36.0") < 0 && - !fixed_param && !is.null(private$variables_) && - length(private$variables_$parameters) == 0) { - stop("Model contains no parameters. Please use 'fixed_param = TRUE'.", call. = FALSE) - } if (fixed_param) { save_warmup <- FALSE } diff --git a/R/path.R b/R/path.R index 3cfc6e3a0..991337dde 100644 --- a/R/path.R +++ b/R/path.R @@ -36,7 +36,7 @@ #' versioned CmdStan installations, the installation with the largest version #' number is used. #' * If no environment variable is found when loaded but any directory in the -#' form `".cmdstan/cmdstan-[version]"` (e.g., `".cmdstan/cmdstan-2.35.0"`), +#' form `".cmdstan/cmdstan-[version]"` (e.g., `".cmdstan/cmdstan-2.37.0"`), #' exists in the user's home directory (*not* the current working directory), #' then the path to the CmdStan installation with the largest version number is #' used for the \R session. On Windows the home directory is determined from @@ -182,7 +182,7 @@ stop_no_path <- function() { } cmdstan_min_version <- function() { - "2.35.0" + "2.37.0" } # Normalize versions for comparison. This is intentionally looser than diff --git a/man-roxygen/model-sample-args.R b/man-roxygen/model-sample-args.R index 95f7fa845..c130ddee2 100644 --- a/man-roxygen/model-sample-args.R +++ b/man-roxygen/model-sample-args.R @@ -75,8 +75,7 @@ #' sampler generates a new sample without changing the current state of the #' Markov chain; only generated quantities may change. This can be useful #' when, for example, trying to generate pseudo-data using the generated -#' quantities block. For CmdStan versions before 2.36, `fixed_param = TRUE` -#' is mandatory if the parameters block is empty. +#' quantities block. #' @param diagnostics (character vector) The diagnostics to automatically check #' and warn about after sampling. Setting this to an empty string `""` or #' `NULL` can be used to prevent CmdStanR from automatically reading in the diff --git a/man/cmdstanr-package.Rd b/man/cmdstanr-package.Rd index 7cdd9051e..dee67236f 100644 --- a/man/cmdstanr-package.Rd +++ b/man/cmdstanr-package.Rd @@ -69,7 +69,7 @@ and is the same license used for CmdStan and the Stan C++ source code. } \section{Getting started}{ CmdStanR requires a working version of CmdStan >= -2.35. If you already have CmdStan installed see \code{\link[=cmdstan_model]{cmdstan_model()}} to get +2.37. If you already have CmdStan installed see \code{\link[=cmdstan_model]{cmdstan_model()}} to get started, otherwise see \code{\link[=install_cmdstan]{install_cmdstan()}} to install CmdStan. The vignette \href{https://mc-stan.org/cmdstanr/articles/cmdstanr.html}{\emph{Getting started with CmdStanR}} demonstrates the basic functionality of the package. diff --git a/man/install_cmdstan.Rd b/man/install_cmdstan.Rd index 089b96468..5f73b0bdd 100644 --- a/man/install_cmdstan.Rd +++ b/man/install_cmdstan.Rd @@ -68,12 +68,12 @@ is \code{NULL}, which downloads the latest stable release from \item{release_url}{(string) The URL for the specific CmdStan release or release candidate to install. See \url{https://github.com/stan-dev/cmdstan/releases}. The URL should point to the tarball (\code{.tar.gz} file) itself, e.g., -\code{release_url="https://github.com/stan-dev/cmdstan/releases/download/v2.35.0/cmdstan-2.35.0.tar.gz"}. +\code{release_url="https://github.com/stan-dev/cmdstan/releases/download/v2.37.0/cmdstan-2.37.0.tar.gz"}. If both \code{version} and \code{release_url} are specified then \code{version} will be used.} \item{release_file}{(string) A file path to a CmdStan release tar.gz file downloaded from the releases page: \url{https://github.com/stan-dev/cmdstan/releases}. -For example: \code{release_file="./cmdstan-2.35.0.tar.gz"}. If \code{release_file} is +For example: \code{release_file="./cmdstan-2.37.0.tar.gz"}. If \code{release_file} is specified then both \code{release_url} and \code{version} will be ignored.} \item{cpp_options}{(list) Any makefile flags/variables to be written to @@ -141,7 +141,7 @@ The \code{check_cmdstan_toolchain()} function attempts to check for the required C++ toolchain. It is called internally by \code{install_cmdstan()} but can also be called directly by the user. -\strong{CmdStan versions older than 2.35.0 are no longer supported.} If you need +\strong{CmdStan versions older than 2.37.0 are no longer supported.} If you need to work with an older CmdStan version we recommend installing an older CmdStanR release from GitHub. } diff --git a/man/model-method-format.Rd b/man/model-method-format.Rd index 27f0cc67c..7fd526b7a 100644 --- a/man/model-method-format.Rd +++ b/man/model-method-format.Rd @@ -32,7 +32,7 @@ to the input model file? The default is \code{FALSE}.} should 'canonicalize' the Stan model, removing things like deprecated syntax. Default is \code{FALSE}. If \code{TRUE}, all canonicalizations are run. You can also supply a list of strings which represent options. In that case the options -are passed to \code{stanc}. See the +are passed to stanc. See the \href{https://mc-stan.org/docs/stan-users-guide/stanc-pretty-printing.html#canonicalizing}{User's guide section} for available canonicalization options.} diff --git a/man/model-method-sample.Rd b/man/model-method-sample.Rd index d2882b228..f871c2a72 100644 --- a/man/model-method-sample.Rd +++ b/man/model-method-sample.Rd @@ -260,8 +260,7 @@ adaptation interval.} sampler generates a new sample without changing the current state of the Markov chain; only generated quantities may change. This can be useful when, for example, trying to generate pseudo-data using the generated -quantities block. For CmdStan versions before 2.36, \code{fixed_param = TRUE} -is mandatory if the parameters block is empty.} +quantities block.} \item{show_messages}{(logical) When \code{TRUE} (the default), prints all output during the execution process, such as iteration numbers and elapsed times. diff --git a/man/model-method-sample_mpi.Rd b/man/model-method-sample_mpi.Rd index b90384dea..5a265e5ba 100644 --- a/man/model-method-sample_mpi.Rd +++ b/man/model-method-sample_mpi.Rd @@ -239,8 +239,7 @@ adaptation interval.} sampler generates a new sample without changing the current state of the Markov chain; only generated quantities may change. This can be useful when, for example, trying to generate pseudo-data using the generated -quantities block. For CmdStan versions before 2.36, \code{fixed_param = TRUE} -is mandatory if the parameters block is empty.} +quantities block.} \item{sig_figs}{(positive integer) The number of significant figures (up to a maximum of 18) to use when storing the output values. If \code{NULL} (the diff --git a/man/set_cmdstan_path.Rd b/man/set_cmdstan_path.Rd index e15d0749c..3fafbfc5f 100644 --- a/man/set_cmdstan_path.Rd +++ b/man/set_cmdstan_path.Rd @@ -52,7 +52,7 @@ session. If it instead points to an existing parent directory containing versioned CmdStan installations, the installation with the largest version number is used. \item If no environment variable is found when loaded but any directory in the -form \code{".cmdstan/cmdstan-[version]"} (e.g., \code{".cmdstan/cmdstan-2.35.0"}), +form \code{".cmdstan/cmdstan-[version]"} (e.g., \code{".cmdstan/cmdstan-2.37.0"}), exists in the user's home directory (\emph{not} the current working directory), then the path to the CmdStan installation with the largest version number is used for the \R session. On Windows the home directory is determined from diff --git a/tests/testthat/helper-envvars-and-paths.R b/tests/testthat/helper-envvars-and-paths.R index 735ac3196..56f8fedf3 100644 --- a/tests/testthat/helper-envvars-and-paths.R +++ b/tests/testthat/helper-envvars-and-paths.R @@ -178,18 +178,3 @@ local_cmdstan_make_local <- function(cpp_options, envir = parent.frame(), local_make_local_backup(envir = envir) cmdstan_make_local(cpp_options = cpp_options, append = append) } - -# Set the CmdStan version the session believes it has and, given a model, -# the version that object reports. The record beside the executable is left -# as written, since assert_current() compares it with the installation, not -# with either cached version. -fake_cmdstan_version <- function(version, mod = NULL) { - .cmdstanr$VERSION <- version - if (!is.null(mod)) { - mod$.__enclos_env__$private$cmdstan_version_ <- version - } -} - -reset_cmdstan_version <- function(mod = NULL) { - fake_cmdstan_version(read_cmdstan_version(cmdstan_path()), mod = mod) -} diff --git a/tests/testthat/test-install.R b/tests/testthat/test-install.R index cd636d4d8..7c597f47b 100644 --- a/tests/testthat/test-install.R +++ b/tests/testthat/test-install.R @@ -25,13 +25,13 @@ test_that("install_cmdstan() successfully installs cmdstan", { test_that("install_cmdstan() errors if installation already exists", { install_dir <- cmdstan_default_install_path() - dir <- file.path(install_dir, "cmdstan-2.35.0") + dir <- file.path(install_dir, "cmdstan-2.37.0") if (!dir.exists(dir)) { dir.create(dir, recursive = TRUE) } expect_warning( install_cmdstan(dir = install_dir, overwrite = FALSE, - version = "2.35.0", wsl = FALSE), + version = "2.37.0", wsl = FALSE), "An installation already exists", fixed = TRUE ) @@ -70,13 +70,13 @@ test_that("install_cmdstan() errors if it times out", { test_that("install_cmdstan() errors if invalid version or URL", { expect_error( - install_cmdstan(version = "2.35.5", wsl = os_is_wsl()), - "Download of CmdStan failed with error: cannot open URL 'https://github.com/stan-dev/cmdstan/releases/download/v2.35.5/cmdstan-2.35.5.tar.gz'\nPlease check if the supplied version number is valid." + install_cmdstan(version = "2.37.5", wsl = os_is_wsl()), + "Download of CmdStan failed with error: cannot open URL 'https://github.com/stan-dev/cmdstan/releases/download/v2.37.5/cmdstan-2.37.5.tar.gz'\nPlease check if the supplied version number is valid." ) expect_error( - install_cmdstan(release_url = "https://github.com/stan-dev/cmdstan/releases/download/v2.35.5/cmdstan-2.35.5.tar.gz", + install_cmdstan(release_url = "https://github.com/stan-dev/cmdstan/releases/download/v2.37.5/cmdstan-2.37.5.tar.gz", wsl = os_is_wsl()), - "Download of CmdStan failed with error: cannot open URL 'https://github.com/stan-dev/cmdstan/releases/download/v2.35.5/cmdstan-2.35.5.tar.gz'\nPlease check if the supplied release URL is valid." + "Download of CmdStan failed with error: cannot open URL 'https://github.com/stan-dev/cmdstan/releases/download/v2.37.5/cmdstan-2.37.5.tar.gz'\nPlease check if the supplied release URL is valid." ) expect_error( install_cmdstan(release_url = "https://github.com/stan-dev/cmdstan/releases/tag/v2.24.0", wsl = os_is_wsl()), @@ -282,8 +282,8 @@ test_that("install_cmdstan() errors for unsupported CmdStan versions", { }) test_that("unsupported release-candidate versions are rejected by the floor check", { - expect_false(is_supported_cmdstan_version("2.34.0-rc1")) - expect_true(is_supported_cmdstan_version("2.35.0-rc1")) + expect_false(is_supported_cmdstan_version("2.36.0-rc1")) + expect_true(is_supported_cmdstan_version("2.37.0-rc1")) expect_error( install_cmdstan(version = "2.34.0-rc1", check_toolchain = FALSE, wsl = os_is_wsl()), "Requested CmdStan version (2.34.0-rc1) is unsupported.", @@ -517,7 +517,7 @@ test_that("install_cmdstan() asks about make/local before downloading", { expect_error( suppressMessages( - install_cmdstan(dir = withr::local_tempdir(), version = "2.36.0", + install_cmdstan(dir = withr::local_tempdir(), version = "2.37.0", check_toolchain = FALSE) ), "Download of CmdStan failed" diff --git a/tests/testthat/test-model-sample.R b/tests/testthat/test-model-sample.R index aa68b418b..688f1ca8e 100644 --- a/tests/testthat/test-model-sample.R +++ b/tests/testthat/test-model-sample.R @@ -293,7 +293,7 @@ test_that("seed works for multi chain sampling", { expect_false(all(chain_tdata_1 == chain_tdata_2)) }) -test_that("Correct behavior if fixed_param not set when the model has no parameters", { +test_that("A model with no parameters samples without fixed_param", { code <- " model {} generated quantities { @@ -302,21 +302,11 @@ test_that("Correct behavior if fixed_param not set when the model has no paramet " stan_file <- write_stan_file(code) m <- cmdstan_model(stan_file) - fake_cmdstan_version("2.35.0", m) - expect_error( - m$sample(), - "Model contains no parameters. Please use 'fixed_param = TRUE'." - ) - - reset_cmdstan_version(m) - if (cmdstan_version_compare(cmdstan_version(), "2.36.0") >= 0) { - # as of 2.36.0 we don't need fixed_param if no parameters - expect_no_error( - utils::capture.output( - fit <- m$sample(iter_warmup = 10, iter_sampling = 10, diagnostics = NULL) - ) + expect_no_error( + utils::capture.output( + fit <- m$sample(iter_warmup = 10, iter_sampling = 10, diagnostics = NULL) ) - } + ) }) diff --git a/tests/testthat/test-path.R b/tests/testthat/test-path.R index 5ea20edb5..c71c240b0 100644 --- a/tests/testthat/test-path.R +++ b/tests/testthat/test-path.R @@ -170,7 +170,7 @@ test_that("Setting path rejects unsupported CmdStan versions", { expect_warning( set_cmdstan_path(path), - "CmdStanR now requires CmdStan v2.35.0 or newer", + "CmdStanR now requires CmdStan v2.37.0 or newer", fixed = TRUE ) expect_null(.cmdstanr$PATH) @@ -255,7 +255,7 @@ test_that("cmdstan_default_path() returns NULL for legacy-only cmdstan directory }) test_that("CmdStan version helpers handle invalid inputs", { - expect_identical(cmdstan_min_version(), "2.35.0") + expect_identical(cmdstan_min_version(), "2.37.0") expect_false(is_supported_cmdstan_version(NULL)) expect_false(is_supported_cmdstan_version("not-a-version")) expect_error(cmdstan_version_compare("", "2.35.0")) diff --git a/vignettes/cmdstanr.Rmd b/vignettes/cmdstanr.Rmd index 496f64923..5a805f9fd 100644 --- a/vignettes/cmdstanr.Rmd +++ b/vignettes/cmdstanr.Rmd @@ -45,7 +45,7 @@ color_scheme_set("brightblue") ## Installing CmdStan -CmdStanR requires a working installation of version 2.35 or later of +CmdStanR requires a working installation of version 2.37 or later of [CmdStan](https://mc-stan.org/users/interfaces/cmdstan.html), the command line interface to Stan. If you don't have CmdStan installed, CmdStanR can install it for you, assuming you have a suitable C++ toolchain. The requirements are @@ -85,7 +85,7 @@ is useful if your CmdStan installation is not located in the default directory that would have been used by `install_cmdstan()` (see #2). 2. If no environment variable is found when loaded but any directory in the form -`".cmdstan/cmdstan-[version]"`, for example `".cmdstan/cmdstan-2.35.0"`, +`".cmdstan/cmdstan-[version]"`, for example `".cmdstan/cmdstan-2.37.0"`, exists in the user's home directory (`Sys.getenv("HOME")`, *not* the current working directory) then the path to the CmdStan with the largest version number will be set as the path to CmdStan for the R session.