Skip to content

Commit e90fda4

Browse files
committed
Merge branch 'expose_new_stan_args' of https://github.com/venpopov/cmdstanr into pr/932
2 parents 6b47912 + a2c4a23 commit e90fda4

8 files changed

Lines changed: 32 additions & 13 deletions

R/args.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,6 @@ SampleArgs <- R6::R6Class(
289289
if (is.logical(self$save_metric)) {
290290
self$save_metric <- as.integer(self$save_metric)
291291
}
292-
if (!self$adapt_engaged & !is.null(self$save_metric)) {
293-
self$save_metric <- 0
294-
}
295292
invisible(self)
296293
},
297294
validate = function(num_procs) {
@@ -820,6 +817,10 @@ validate_sample_args <- function(self, num_procs) {
820817
len = 1,
821818
null.ok = TRUE)
822819

820+
if (is.null(self$adapt_engaged) || (!self$adapt_engaged && !is.null(self$save_metric))) {
821+
self$save_metric <- 0
822+
}
823+
823824
invisible(TRUE)
824825
}
825826

R/run.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ CmdStanRun <- R6::R6Class(
7676
},
7777
config_files = function(include_failed = FALSE) {
7878
files <- private$config_files_
79-
if (!length(files) || !any(file.exists(files))) {
79+
files_win_path <- sapply(private$config_files_, wsl_safe_path, revert = TRUE)
80+
if (!length(files) || !any(file.exists(files_win_path))) {
8081
stop(
8182
"No CmdStan config files found. ",
8283
"Set 'save_cmdstan_config=TRUE' when fitting the model.",
@@ -92,7 +93,8 @@ CmdStanRun <- R6::R6Class(
9293
},
9394
metric_files = function(include_failed = FALSE) {
9495
files <- private$metric_files_
95-
if (!length(files) || !any(file.exists(files))) {
96+
files_win_path <- sapply(private$metric_files_, wsl_safe_path, revert = TRUE)
97+
if (!length(files) || !any(file.exists(files_win_path))) {
9698
stop(
9799
"No metric files found. ",
98100
"Set 'save_metric=TRUE' when fitting the model.",

man/model-method-laplace.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/model-method-optimize.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/model-method-pathfinder.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/model-method-sample_mpi.Rd

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/model-method-variational.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-model-output_dir.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,24 @@ test_that("all fitting methods work with output_dir", {
3333
# from the original tempdir(), so need to normalise both for comparison
3434
expect_equal(normalizePath(fit$runset$args$output_dir),
3535
normalizePath(method_dir))
36-
files <- list.files(method_dir, full.names = TRUE)
36+
files <- normalizePath(list.files(method_dir, full.names = TRUE))
3737
# in 2.34.0 we also save the config files for all methods and the metric
3838
# for sample
3939
if (cmdstan_version() < "2.34.0") {
4040
mult <- 1
4141
} else if (method == "sample") {
4242
mult <- 3
43-
expect_equal(repair_path(files[grepl("metric", files)]), fit$metric_files())
44-
expect_equal(repair_path(files[grepl("config", files)]), fit$config_files())
43+
expect_equal(files[grepl("metric", files)],
44+
normalizePath(sapply(fit$metric_files(), wsl_safe_path, revert = TRUE,
45+
USE.NAMES = FALSE)))
46+
expect_equal(files[grepl("config", files)],
47+
normalizePath(sapply(fit$config_files(), wsl_safe_path, revert = TRUE,
48+
USE.NAMES = FALSE)))
4549
} else {
4650
mult <- 2
47-
expect_equal(repair_path(files[grepl("config", files)]), fit$config_files())
51+
expect_equal(files[grepl("config", files)],
52+
normalizePath(sapply(fit$config_files(), wsl_safe_path, revert = TRUE,
53+
USE.NAMES = FALSE)))
4854
}
4955
expect_equal(length(list.files(method_dir)), mult * fit$num_procs())
5056

0 commit comments

Comments
 (0)