Skip to content

Commit 418b1c5

Browse files
authored
Merge pull request #1159 from stan-dev/more-outdated-code
Remove more outdated code for v1.0
2 parents 509a277 + d2fa15e commit 418b1c5

44 files changed

Lines changed: 219 additions & 388 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/R-CMD-check-wsl.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959

6060
- name: Install cmdstan
6161
run: |
62-
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
62+
cmdstanr::check_cmdstan_toolchain()
6363
cmdstanr::install_cmdstan(cores = 2, wsl = TRUE, overwrite = TRUE)
6464
shell: Rscript {0}
6565

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ jobs:
115115

116116
- name: Install cmdstan
117117
run: |
118-
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
118+
cmdstanr::check_cmdstan_toolchain()
119119
tarball_url <- Sys.getenv("CMDSTAN_TEST_TARBALL_URL")
120120
if (nzchar(tarball_url)) {
121121
cmdstanr::install_cmdstan(

.github/workflows/Test-coverage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555

5656
- name: Install cmdstan
5757
run: |
58-
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
58+
cmdstanr::check_cmdstan_toolchain()
5959
cmdstanr::install_cmdstan(cores = 2)
6060
shell: Rscript {0}
6161

NEWS.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
# cmdstanr (development version)
22

3+
* Informative error when exposing functions using names that are reserved
4+
keywords (@VisruthSK, #1154)
5+
* `save_cmdstan_config` and `save_metric` default to `FALSE` but can be
6+
set to `TRUE` for an entire R session via new global options. (#1159)
7+
38
* CmdStanModel objects created using `compile_model_methods = TRUE` that are
49
then saved and reloaded no longer error in model fitting methods. Model methods
5-
are recompiled lazily if needed.
10+
are recompiled lazily if needed. (#1158)
611

7-
* CmdStan versions older than 2.35.0 are no longer supported.
8-
* Minimum R version increased to 4.0.0.
9-
* Removed legacy Windows toolchain paths for older CmdStan releases.
10-
* `CMDSTANR_USE_MSYS_TOOLCHAIN` is now deprecated and ignored (with a warning).
12+
* CmdStan versions older than 2.35.0 are no longer supported. (#1144)
13+
* Minimum R version increased to 4.0.0. (#1144)
14+
* Removed legacy Windows toolchain paths for older CmdStan releases. (#1144)
15+
* `CMDSTANR_USE_MSYS_TOOLCHAIN` is now deprecated and ignored (with a warning). (#1144)
1116

12-
* Removed deprecated items (replacements in parentheses):
17+
* Removed deprecated items (replacements in parentheses). (#1061)
1318
- `read_sample_csv()` (`read_cmdstan_csv()`)
1419
- `write_stan_tempfile()` (`write_stan_file()`)
1520
- `jacobian_adjustment` argument to `fit$log_prob()` and similar methods (`jacobian` argument)

R/args.R

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,6 @@ validate_cmdstan_args <- function(self) {
692692
checkmate::assert_integerish(self$refresh, lower = 0, null.ok = TRUE)
693693
checkmate::assert_integerish(self$sig_figs, lower = 1, upper = 18, null.ok = TRUE)
694694
checkmate::assert_integerish(self$save_cmdstan_config, lower = 0, upper = 1, len = 1, null.ok = TRUE)
695-
if (!is.null(self$sig_figs) && cmdstan_version() < "2.25") {
696-
warning("The 'sig_figs' argument is only supported with cmdstan 2.25+ and will be ignored!", call. = FALSE)
697-
}
698695
if (!is.null(self$refresh)) {
699696
self$refresh <- as.integer(self$refresh)
700697
}
@@ -710,9 +707,6 @@ validate_cmdstan_args <- function(self) {
710707
validate_init(self$init, num_inits)
711708
validate_seed(self$seed, num_procs)
712709
if (!is.null(self$opencl_ids)) {
713-
if (cmdstan_version() < "2.26") {
714-
stop("Runtime selection of OpenCL devices is only supported with CmdStan version 2.26 or newer.", call. = FALSE)
715-
}
716710
checkmate::assert_vector(self$opencl_ids, len = 2)
717711
}
718712
invisible(TRUE)
@@ -830,9 +824,6 @@ validate_optimize_args <- function(self) {
830824
choices = c("bfgs", "lbfgs", "newton"))
831825
checkmate::assert_flag(self$jacobian, null.ok = TRUE)
832826
if (!is.null(self$jacobian)) {
833-
if (cmdstan_version() < "2.32") {
834-
warning("The 'jacobian' argument is only supported with cmdstan 2.32+ and will be ignored!", call. = FALSE)
835-
}
836827
self$jacobian <- as.integer(self$jacobian)
837828
}
838829

@@ -1494,12 +1485,7 @@ validate_seed <- function(seed, num_procs) {
14941485
if (is.null(seed)) {
14951486
return(invisible(TRUE))
14961487
}
1497-
if (cmdstan_version() < "2.26") {
1498-
lower_seed <- 1
1499-
} else {
1500-
lower_seed <- 0
1501-
}
1502-
checkmate::assert_integerish(seed, lower = lower_seed)
1488+
checkmate::assert_integerish(seed, lower = 0)
15031489
if (length(seed) > 1 && length(seed) != num_procs) {
15041490
stop("If 'seed' is specified it must be a single integer or one per chain.",
15051491
call. = FALSE)

R/cmdstanr-package.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@
3535
#'
3636
"_PACKAGE"
3737

38-
if (getRversion() >= "2.15.1") utils::globalVariables(c("self", "private", "super"))
38+
utils::globalVariables(c("self", "private", "super"))

R/cpp_opts.R

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,24 @@ parse_exe_info_string <- function(ret_stdout) {
5252
# old (current) parser
5353
model_compile_info <- function(exe_file, version) {
5454
info <- NULL
55-
if (version > "2.26.1") {
56-
57-
ret <- run_info_cli(exe_file)
58-
if (ret$status == 0) {
59-
info <- list()
60-
info_raw <- strsplit(strsplit(ret$stdout, "\n")[[1]], "=")
61-
for (key_val in info_raw) {
62-
if (length(key_val) > 1) {
63-
key_val <- trimws(key_val)
64-
val <- key_val[2]
65-
if (!is.na(as.logical(val))) {
66-
val <- as.logical(val)
67-
}
68-
info[[toupper(key_val[1])]] <- val
55+
ret <- run_info_cli(exe_file)
56+
if (ret$status == 0) {
57+
info <- list()
58+
info_raw <- strsplit(strsplit(ret$stdout, "\n")[[1]], "=")
59+
for (key_val in info_raw) {
60+
if (length(key_val) > 1) {
61+
key_val <- trimws(key_val)
62+
val <- key_val[2]
63+
if (!is.na(as.logical(val))) {
64+
val <- as.logical(val)
6965
}
66+
info[[toupper(key_val[1])]] <- val
7067
}
71-
info[["STAN_VERSION"]] <- paste0(info[["STAN_VERSION_MAJOR"]], ".", info[["STAN_VERSION_MINOR"]], ".", info[["STAN_VERSION_PATCH"]])
72-
info[["STAN_VERSION_MAJOR"]] <- NULL
73-
info[["STAN_VERSION_MINOR"]] <- NULL
74-
info[["STAN_VERSION_PATCH"]] <- NULL
7568
}
69+
info[["STAN_VERSION"]] <- paste0(info[["STAN_VERSION_MAJOR"]], ".", info[["STAN_VERSION_MINOR"]], ".", info[["STAN_VERSION_PATCH"]])
70+
info[["STAN_VERSION_MAJOR"]] <- NULL
71+
info[["STAN_VERSION_MINOR"]] <- NULL
72+
info[["STAN_VERSION_PATCH"]] <- NULL
7673
}
7774
info
7875
}

R/data.R

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,15 @@
2020
#' The `list` to `array` conversion is intended to make it easier to prepare
2121
#' the data for certain Stan declarations involving arrays:
2222
#'
23-
#' * `vector[J] v[K]` (or equivalently `array[K] vector[J] v ` as of Stan 2.27)
24-
#' can be constructed in \R as a list with `K` elements where each element a
25-
#' vector of length `J`
26-
#' * `matrix[I,J] v[K]` (or equivalently `array[K] matrix[I,J] m ` as of Stan
27-
#' 2.27 ) can be constructed in \R as a list with `K` elements where each element
28-
#' an `IxJ` matrix
23+
#' * `array[K] vector[J] v ` can be constructed in \R as a list with `K`
24+
#' elements where each element a vector of length `J`
25+
#' * `array[K] matrix[I,J] m ` can be constructed in \R as a list with `K`
26+
#' elements where each element an `IxJ` matrix
2927
#'
3028
#' These can also be passed in from \R as arrays instead of lists but the list
3129
#' option is provided for convenience. Unfortunately for arrays with more than
32-
#' one dimension, e.g., `vector[J] v[K,L]` (or equivalently
33-
#' `array[K,L] vector[J] v ` as of Stan 2.27) it is not possible to use an \R
34-
#' list and an array must be used instead. For this example the array in \R
30+
#' one dimension (e.g. `array[K,L] vector[J] v `) it is not possible to use an
31+
#' \R list and an array must be used instead. For this example the array in \R
3532
#' should have dimensions `KxLxJ`.
3633
#'
3734
#' @examples
@@ -49,7 +46,7 @@
4946
#'
5047
#'
5148
#' # demonstrating list to array conversion
52-
#' # suppose x is declared as `vector[3] x[2]` (or equivalently `array[2] vector[3] x`)
49+
#' # suppose x is declared as `array[2] vector[3] x`
5350
#' # we can use a list of length 2 where each element is a vector of length 3
5451
#' data <- list(x = list(1:3, 4:6))
5552
#' file <- tempfile(fileext = ".json")
@@ -159,14 +156,6 @@ process_data <- function(data, model_variables = NULL) {
159156
} else if (is.character(data)) {
160157
path <- absolute_path(data)
161158
} else if (is.list(data) && !is.data.frame(data)) {
162-
if (cmdstan_version() < "2.22" && any_zero_dims(data)) {
163-
stop(
164-
"Data includes 0-dimensional data structures. To use this data please ",
165-
"either update your CmdStan installation with install_cmdstan() ",
166-
"or specify data as a file created by rstan::stan_rdump().",
167-
call. = FALSE
168-
)
169-
}
170159
if (!is.null(model_variables)) {
171160
data_variables <- model_variables$data
172161
is_data_supplied <- names(data_variables) %in% names(data)

R/fit.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,8 +1205,8 @@ CmdStanFit$set("public", name = "return_codes", value = return_codes)
12051205
#' profiling data if any profiling data was written to the profile CSV files.
12061206
#' See [save_profile_files()] to control where the files are saved.
12071207
#'
1208-
#' Support for profiling Stan programs is available with CmdStan >= 2.26 and
1209-
#' requires adding profiling statements to the Stan program.
1208+
#' Profiling requires adding profiling statements to the Stan program. See
1209+
#' **Examples** for a demonstration.
12101210
#'
12111211
#' @return A list of data frames with profiling data if the profiling CSV files
12121212
#' were created.

R/install.R

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ install_cmdstan <- function(dir = NULL,
108108
.cmdstanr$WSL <- FALSE
109109
}
110110
if (check_toolchain) {
111-
check_cmdstan_toolchain(fix = FALSE, quiet = quiet)
111+
check_cmdstan_toolchain(quiet = quiet)
112112
}
113113
make_local_msg <- NULL
114114
if (!is.null(cmdstan_version(error_on_NA = FALSE))) {
@@ -336,17 +336,20 @@ cmdstan_make_local <- function(dir = cmdstan_path(),
336336

337337
#' @rdname install_cmdstan
338338
#' @export
339-
#' @param fix For `check_cmdstan_toolchain()`, should CmdStanR attempt to fix
340-
#' any detected toolchain problems? The default is `FALSE`.
341-
#' This argument is currently ignored and retained for compatibility.
339+
#' @param fix As of v1.0 this argument is deprecated and ignored and only
340+
#' retained for compatibility.
342341
#'
343342
check_cmdstan_toolchain <- function(fix = FALSE, quiet = FALSE) {
343+
if (isTRUE(fix)) {
344+
warning("The 'fix' argument is deprecated and will be removed in a future release.",
345+
call. = FALSE)
346+
}
344347
warn_if_ignored_msys_toolchain_env()
345348
if (os_is_windows()) {
346349
if (os_is_wsl()) {
347350
check_wsl_toolchain()
348351
} else {
349-
check_rtools4x_windows_toolchain(fix = fix, quiet = quiet)
352+
check_rtools4x_windows_toolchain(quiet = quiet)
350353
}
351354
} else {
352355
check_unix_make()
@@ -593,7 +596,7 @@ check_wsl_toolchain <- function() {
593596
}
594597
}
595598

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

698701
cmdstan_arch_suffix <- function(version = NULL) {
699702
os_needs_arch <- os_is_linux() || os_is_wsl()
700-
if ((!is.null(version) && version < "2.26") || !os_needs_arch) {
701-
# pre-CmdStan 2.26, only the x86 tarball was provided
703+
if (!os_needs_arch) {
702704
return(NULL)
703705
}
704706

0 commit comments

Comments
 (0)