Skip to content

Commit be63f37

Browse files
committed
make the gq time tests conditional on stan version
1 parent 98ece20 commit be63f37

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

tests/testthat/test-csv.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,13 @@ test_that("returning time works for gq read_cmdstan_csv from fit object", {
557557
ncols = 2
558558
)
559559
expect_named(gq_csv$time$chains, c("chain_id", "total"))
560-
expect_true(all(gq_csv$time$chains$total > 0))
560+
if (cmdstan_version() >= "2.39.0") {
561+
# per-chain times should be non-zero (parsed from CmdStan timing output)
562+
expect_true(all(gq_csv$time$chains$total > 0))
563+
} else {
564+
# for version < 2.39 per-chain times are reported as 0
565+
expect_true(all(gq_csv$time$chains$total == 0))
566+
}
561567
})
562568

563569
test_that("gq time from read_cmdstan_csv matches time from fit_gq$time()", {

tests/testthat/test-fit-gq.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,15 @@ test_that("time() works after gq", {
119119
ncols = 2
120120
)
121121
expect_named(run_times$chains, c("chain_id", "total"))
122-
# per-chain times should be non-zero (parsed from CmdStan timing output)
123-
expect_true(all(run_times$chains$total > 0))
122+
# total wall-clock time is always positive
124123
expect_true(run_times$total > 0)
124+
if (cmdstan_version() >= "2.39.0") {
125+
# CmdStan >= 2.39 reports per-chain timing for generated quantities
126+
expect_true(all(run_times$chains$total > 0))
127+
} else {
128+
# for CmdStan < 2.39 per-chain times are reported as 0
129+
expect_true(all(run_times$chains$total == 0))
130+
}
125131
})
126132

127133
test_that("fitted_params_files() works", {

0 commit comments

Comments
 (0)