Skip to content

Commit

Permalink
Merge branch 'master' into model-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed Jan 22, 2024
2 parents 269f90a + cd7b94b commit a4750aa
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 25 deletions.
3 changes: 3 additions & 0 deletions R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,9 @@ compile <- function(quiet = TRUE,
error_on_status = FALSE
)
}

writeLines(private$model_methods_env_$hpp_code_,
con = wsl_safe_path(private$hpp_file_, revert = TRUE))
} # End - if(!dry_run)

private$exe_file_ <- exe
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ get_standalone_hpp <- function(stan_file, stancflags) {
),
wsl_compatible_run(
command = stanc_cmd(),
args = c(paste0("--o=", hpp_path), stancflags, stan_file),
args = c(paste0("--o=", wsl_safe_path(hpp_path)), stancflags, wsl_safe_path(stan_file)),
wd = cmdstan_path(),
error_on_status = FALSE
)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-install.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test_that("install_cmdstan() successfully installs cmdstan", {
install_cmdstan(dir = dir, cores = 2, quiet = FALSE, overwrite = TRUE,
release_url = cmdstan_test_tarball_url,
wsl = os_is_wsl()),
"Compiling, linking C++ code",
"Compiling C++ code",
fixed = TRUE
),
"CmdStan path set",
Expand Down
20 changes: 0 additions & 20 deletions tests/testthat/test-model-compile.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,6 @@ test_that("compile errors are shown", {
)
})

test_that("compile suggests using format to fix old syntax", {
stan_file <- testing_stan_file("old_array_syntax")
expect_error(
cmdstan_model(stan_file),
"To fix deprecated or removed syntax please see ?cmdstanr::format for an example.",
fixed = TRUE
)
})

test_that("dir arg works for cmdstan_model and $compile()", {
tmp_dir <- tempdir()
tmp_dir_2 <- tempdir()
Expand Down Expand Up @@ -689,16 +680,6 @@ test_that("format() works", {
fixed = TRUE
)

expect_output(
mod_1$format(canonicalize = TRUE),
"target += normal_lpdf(y | 0, 1);",
fixed = TRUE
)
expect_output(
mod_1$format(canonicalize = list("deprecations")),
"target += normal_lpdf(y | 0, 1);",
fixed = TRUE
)
expect_error(
mod_1$format(),
"Syntax error found! See the message above for more information.",
Expand Down Expand Up @@ -868,4 +849,3 @@ test_that("STANCFLAGS included from make/local", {
expect_output(print(out), out_w_flags)
cmdstan_make_local(cpp_options = make_local_old, append = FALSE)
})

4 changes: 3 additions & 1 deletion tests/testthat/test-model-laplace.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ test_that("laplace() runs when all arguments specified validly", {
expect_equal(fit1$metadata()$draws, as.integer(ok_arg_values$draws))
expect_equal(fit1$mode()$metadata()$jacobian, as.integer(ok_arg_values$jacobian))
expect_equal(fit1$mode()$metadata()$init_alpha, ok_arg_values$opt_args$init_alpha)
expect_equal(fit1$mode()$metadata()$tol_obj, ok_arg_values$opt_args$tol_obj, tolerance = 0)

# https://github.com/stan-dev/cmdstan/issues/1242
#expect_equal(fit1$mode()$metadata()$tol_obj, ok_arg_values$opt_args$tol_obj, tolerance = 0)

# leaving all at default (except 'data')
expect_laplace_output(fit2 <- mod$laplace(data = data_list, seed = 123))
Expand Down
6 changes: 4 additions & 2 deletions tests/testthat/test-model-optimize.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ test_that("optimize() works with (L-)BFGS tolerances specified", {
expect_equal(metadata$init_alpha, 0.002)
expect_equal(metadata$tol_obj, 2e-11)
expect_equal(metadata$tol_rel_obj, 10001)
expect_equal(metadata$tol_grad, 5e-07)
# https://github.com/stan-dev/cmdstan/issues/1242
# expect_equal(metadata$tol_grad, 5e-07)
expect_equal(metadata$tol_rel_grad, 10000001)
expect_equal(metadata$tol_param, 5e-07)
# https://github.com/stan-dev/cmdstan/issues/1242
# expect_equal(metadata$tol_param, 5e-07)
expect_equal(metadata$history_size, 6)
})

Expand Down

0 comments on commit a4750aa

Please sign in to comment.