Skip to content

Commit 5f2a8c8

Browse files
authored
Merge pull request #1098 from katrinabrock/1097
fix read_cmdstan_csv tilde issue
2 parents c57888e + bafae1f commit 5f2a8c8

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Imports:
4848
rlang (>= 0.4.7)
4949
Suggests:
5050
bayesplot,
51+
fs,
5152
ggplot2,
5253
knitr (>= 1.37),
5354
loo (>= 2.0.0),

R/csv.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ read_cmdstan_csv <- function(files,
254254
"\""
255255
)
256256
} else {
257-
fread_cmd <- paste0("grep -v '^#' --color=never '", output_file, "'")
257+
fread_cmd <- paste0("grep -v '^#' --color=never '", path.expand(output_file), "'")
258258
}
259259
if (length(sampler_diagnostics) > 0) {
260260
post_warmup_sd_id <- length(post_warmup_sampler_diagnostics) + 1

tests/testthat/test-csv.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,3 +888,11 @@ test_that("read_cmdstan_csv works if no variables are specified", {
888888
read_cmdstan_csv(fit_bernoulli_thin_1$output_files(), variables = "", sampler_diagnostics = "")
889889
)
890890
})
891+
892+
test_that("read_cmdstan_csv() works with tilde expansion", {
893+
skip_if(os_is_windows())
894+
full_path <- test_path("resources", "csv", "model1-1-warmup.csv")
895+
expect_no_error(read_cmdstan_csv(full_path))
896+
tildified_path <- file.path("~", fs::path_rel(full_path, "~"))
897+
expect_no_error(read_cmdstan_csv(tildified_path))
898+
})

0 commit comments

Comments
 (0)