From a15298b281fc6a5ce126c93349015039c8967791 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 10 Jan 2024 13:17:16 +0200 Subject: [PATCH] Update expect draws format in tests --- tests/testthat/test-model-methods.R | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/testthat/test-model-methods.R b/tests/testthat/test-model-methods.R index c3607f7b..74419717 100644 --- a/tests/testthat/test-model-methods.R +++ b/tests/testthat/test-model-methods.R @@ -221,20 +221,20 @@ test_that("unconstrain_draws returns correct values", { mod <- cmdstan_model(write_stan_file(model_code), compile_model_methods = TRUE, force_recompile = TRUE) - fit <- mod$sample(data = list(N = 0), chains = 1) + fit <- mod$sample(data = list(N = 0), chains = 2) x_draws <- fit$draws(format = "draws_df")$x # Unconstrain all internal draws - unconstrained_internal_draws <- fit$unconstrain_draws()[[1]] + unconstrained_internal_draws <- fit$unconstrain_draws() expect_equal(as.numeric(x_draws), as.numeric(unconstrained_internal_draws)) # Unconstrain external CmdStan CSV files - unconstrained_csv <- fit$unconstrain_draws(files = fit$output_files())[[1]] + unconstrained_csv <- fit$unconstrain_draws(files = fit$output_files()) expect_equal(as.numeric(x_draws), as.numeric(unconstrained_csv)) # Unconstrain existing draws object - unconstrained_draws <- fit$unconstrain_draws(draws = fit$draws())[[1]] + unconstrained_draws <- fit$unconstrain_draws(draws = fit$draws()) expect_equal(as.numeric(x_draws), as.numeric(unconstrained_draws)) # With a lower-bounded constraint, the parameter draws should be the @@ -253,19 +253,19 @@ test_that("unconstrain_draws returns correct values", { mod <- cmdstan_model(write_stan_file(model_code), compile_model_methods = TRUE, force_recompile = TRUE) - fit <- mod$sample(data = list(N = 0), chains = 1) + fit <- mod$sample(data = list(N = 0), chains = 2) x_draws <- fit$draws(format = "draws_df")$x - unconstrained_internal_draws <- fit$unconstrain_draws()[[1]] + unconstrained_internal_draws <- fit$unconstrain_draws() expect_equal(as.numeric(x_draws), exp(as.numeric(unconstrained_internal_draws))) # Unconstrain external CmdStan CSV files - unconstrained_csv <- fit$unconstrain_draws(files = fit$output_files())[[1]] + unconstrained_csv <- fit$unconstrain_draws(files = fit$output_files()) expect_equal(as.numeric(x_draws), exp(as.numeric(unconstrained_csv))) # Unconstrain existing draws object - unconstrained_draws <- fit$unconstrain_draws(draws = fit$draws())[[1]] + unconstrained_draws <- fit$unconstrain_draws(draws = fit$draws()) expect_equal(as.numeric(x_draws), exp(as.numeric(unconstrained_draws))) })