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 NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion R/cmdstanr-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#'
Expand Down Expand Up @@ -60,11 +60,11 @@
#' @param release_url (string) The URL for the specific CmdStan release or
#' release candidate to install. See <https://github.com/stan-dev/cmdstan/releases>.
#' 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: <https://github.com/stan-dev/cmdstan/releases>.
#' 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
Expand Down
5 changes: 0 additions & 5 deletions R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions R/path.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions man-roxygen/model-sample-args.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion man/cmdstanr-package.Rd

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

6 changes: 3 additions & 3 deletions man/install_cmdstan.Rd

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

2 changes: 1 addition & 1 deletion man/model-method-format.Rd

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

3 changes: 1 addition & 2 deletions man/model-method-sample.Rd

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

3 changes: 1 addition & 2 deletions man/model-method-sample_mpi.Rd

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

2 changes: 1 addition & 1 deletion man/set_cmdstan_path.Rd

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

15 changes: 0 additions & 15 deletions tests/testthat/helper-envvars-and-paths.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
18 changes: 9 additions & 9 deletions tests/testthat/test-install.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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"
Expand Down
20 changes: 5 additions & 15 deletions tests/testthat/test-model-sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
)
}
)
})


Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-path.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"))
Expand Down
4 changes: 2 additions & 2 deletions vignettes/cmdstanr.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Loading