diff --git a/R/model.R b/R/model.R index e17ffbd4..c7391b33 100644 --- a/R/model.R +++ b/R/model.R @@ -2399,7 +2399,7 @@ model_compile_info <- function(exe_file) { if (!is.na(as.logical(val))) { val <- as.logical(val) } - info[[toupper(key_val[1])]] <- val + info[[tolower(key_val[1])]] <- val } } info[["STAN_VERSION"]] <- paste0(info[["STAN_VERSION_MAJOR"]], ".", info[["STAN_VERSION_MINOR"]], ".", info[["STAN_VERSION_PATCH"]]) diff --git a/tests/testthat/test-example.R b/tests/testthat/test-example.R index 8d14d5d0..157929e0 100644 --- a/tests/testthat/test-example.R +++ b/tests/testthat/test-example.R @@ -1,7 +1,7 @@ context("cmdstanr_example") test_that("cmdstanr_example works", { - fit_mcmc <- cmdstanr_example("logistic", chains = 2) + fit_mcmc <- cmdstanr_example("logistic", chains = 2, force_recompile = TRUE) checkmate::expect_r6(fit_mcmc, "CmdStanMCMC") expect_equal(fit_mcmc$num_chains(), 2) diff --git a/tests/testthat/test-opencl.R b/tests/testthat/test-opencl.R index 55c59e2c..35674183 100644 --- a/tests/testthat/test-opencl.R +++ b/tests/testthat/test-opencl.R @@ -117,3 +117,14 @@ test_that("error for runtime selection of OpenCL devices if version less than 2. ) reset_cmdstan_version() }) + +test_that("model from exe_file retains open_cl option", { + skip_if_not(Sys.getenv("CMDSTANR_OPENCL_TESTS") %in% c("1", "true")) + stan_file <- testing_stan_file("bernoulli") + exe_file <- tempfile('bernoulli-') + mod <- cmdstan_model(stan_file = stan_file, exe_file = exe_file, cpp_options = list(stan_opencl = TRUE)) + mod_from_exe <- cmdstan_model(exe_file = exe_file) + expect_sample_output( + fit <- mod_from_exe$sample(data = testing_data("bernoulli"), opencl_ids = c(0, 0), chains = 1) + ) +}) \ No newline at end of file diff --git a/tests/testthat/test-threads.R b/tests/testthat/test-threads.R index 1a333e82..7bf8338f 100644 --- a/tests/testthat/test-threads.R +++ b/tests/testthat/test-threads.R @@ -178,3 +178,22 @@ test_that("correct output when stan_threads not TRUE", { fixed = TRUE ) }) + +test_that('correct output when stan threads set via make local',{ + #TODO clean this up so no leftover changes to make local + file.copy( + file.path(cmdstan_path(), 'make', 'local'), + file.path(cmdstan_path(), 'make', 'local.save') + ) + on.exit(file.rename( + file.path(cmdstan_path(), 'make', 'local.save'), + file.path(cmdstan_path(), 'make', 'local') + ), add = TRUE, after = FALSE) + cmdstan_make_local(cpp_options = list(stan_threads = TRUE)) + mod <- cmdstan_model(stan_program, force_recompile = TRUE) + expect_output( + f <- mod$sample(data = data_file_json, parallel_chains = 4, threads_per_chain = 1), + "Running MCMC with 4 parallel chains, with 1 thread(s) per chain..", + fixed = TRUE + ) +})