Skip to content

Commit 5527cdb

Browse files
committed
Re-added old test
1 parent 93e2b32 commit 5527cdb

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tests/testthat/test-csv.R

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,6 @@ test_that("as_cmdstan_fit handles parameter names with parentheses and indices",
914914
skip_on_cran()
915915

916916
csv_file <- withr::local_tempfile(fileext = ".csv")
917-
918917
lines <- c(
919918
"# model = norm_model",
920919
"# method = sample (Default)",
@@ -937,3 +936,29 @@ test_that("as_cmdstan_fit handles parameter names with parentheses and indices",
937936
dims <- fit$metadata()$stan_variable_sizes
938937
expect_equal(dims[["Sigma"]], c(2, 2))
939938
})
939+
940+
test_that("as_cmdstan_fit handles variable names with parentheses", {
941+
skip_on_cran()
942+
csv_file <- withr::local_tempfile(fileext = ".csv")
943+
writeLines(c(
944+
"# model = norm_model",
945+
"# method = sample (Default)",
946+
"# id = 1",
947+
"# thin = 1",
948+
"# save_warmup = 0",
949+
"THETA4,SIGMA(1,1)",
950+
"2.00000E+00,2.00000E+00",
951+
"2.00000E+00,2.00000E+00"
952+
), con = csv_file)
953+
954+
expect_no_error({
955+
fit <- as_cmdstan_fit(csv_file, check_diagnostics = FALSE, format = "draws_matrix")
956+
})
957+
958+
draws <- fit$draws()
959+
vars <- posterior::variables(draws)
960+
961+
expect_equal(posterior::ndraws(draws), 2L)
962+
expect_true(any(grepl("THETA4", vars)))
963+
expect_true(any(grepl("SIGMA", vars)))
964+
})

0 commit comments

Comments
 (0)