Skip to content

Commit cc82e59

Browse files
committed
specify minimum data.table version and condition tests on cmdstan version
1 parent 9cd12fb commit cc82e59

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Depends:
4040
R (>= 4.0.0)
4141
Imports:
4242
checkmate,
43-
data.table,
43+
data.table (>= 1.11.6),
4444
jsonlite (>= 1.8.7),
4545
posterior (>= 1.5.0),
4646
processx (>= 3.5.0),

tests/testthat/test-csv.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,16 +398,20 @@ test_that("read_cmdstan_csv() works for pathfinder", {
398398
"lp__", "lp_approx__", "path__", "alpha",
399399
"beta[1]", "beta[2]", "beta[3]"
400400
)
401+
if (cmdstan_version() < "2.37.0") {
402+
# the path__ column was added to pathfinder output in CmdStan 2.37
403+
expected_variables <- setdiff(expected_variables, "path__")
404+
}
401405
expect_equal(posterior::variables(csv_output$draws), expected_variables)
402406
expect_equal(csv_output$metadata$variables, expected_variables)
403407

404408
filtered_output <- read_cmdstan_csv(
405409
fit_logistic_pathfinder$output_files(),
406-
variables = c("path__", "lp_approx__")
410+
variables = c("lp_approx__", "lp__")
407411
)
408412
expect_equal(
409413
posterior::variables(filtered_output$draws),
410-
c("path__", "lp_approx__")
414+
c("lp_approx__", "lp__")
411415
)
412416
})
413417

tests/testthat/test-model-pathfinder.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ expect_pathfinder_output <- function(object, num_chains = NULL) {
103103
test_that("Pathfinder Runs", {
104104
expect_pathfinder_output(fit <- mod$pathfinder(data=data_list, seed=1234, refresh = 0))
105105
expect_s3_class(fit, "CmdStanPathfinder")
106-
expect_equal(
107-
posterior::variables(fit$draws()),
108-
c("lp__", "lp_approx__", "path__", "theta")
109-
)
106+
expected_variables <- c("lp__", "lp_approx__", "path__", "theta")
107+
if (cmdstan_version() < "2.37.0") {
108+
# the path__ column was added to pathfinder output in CmdStan 2.37
109+
expected_variables <- setdiff(expected_variables, "path__")
110+
}
111+
expect_equal(posterior::variables(fit$draws()), expected_variables)
110112
})
111113

112114
test_that("pathfinder() method works with data files", {

0 commit comments

Comments
 (0)