From 0c2179e75bdfed0fa60af9aa6480fc587f8a1548 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 7 May 2024 20:15:34 +0300 Subject: [PATCH] Add default num_paths to fix init error --- R/model.R | 2 +- man/model-method-pathfinder.Rd | 2 +- tests/testthat/test-model-pathfinder.R | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/R/model.R b/R/model.R index 35489171..f9b8241c 100644 --- a/R/model.R +++ b/R/model.R @@ -1939,7 +1939,7 @@ pathfinder <- function(data = NULL, history_size = NULL, single_path_draws = NULL, draws = NULL, - num_paths = NULL, + num_paths = 4, max_lbfgs_iters = NULL, num_elbo_draws = NULL, save_single_paths = NULL, diff --git a/man/model-method-pathfinder.Rd b/man/model-method-pathfinder.Rd index 61590cbb..c3a2044b 100644 --- a/man/model-method-pathfinder.Rd +++ b/man/model-method-pathfinder.Rd @@ -25,7 +25,7 @@ pathfinder( history_size = NULL, single_path_draws = NULL, draws = NULL, - num_paths = NULL, + num_paths = 4, max_lbfgs_iters = NULL, num_elbo_draws = NULL, save_single_paths = NULL, diff --git a/tests/testthat/test-model-pathfinder.R b/tests/testthat/test-model-pathfinder.R index 0860ba27..3eba55ab 100644 --- a/tests/testthat/test-model-pathfinder.R +++ b/tests/testthat/test-model-pathfinder.R @@ -124,6 +124,11 @@ test_that("pathfinder() method works with init file", { expect_pathfinder_output(mod$pathfinder(data = data_file_r, init = init_file)) }) +test_that("pathfinder() method works with init function and default paths", { + init_function <- function() { list(theta = 0.5) } + expect_pathfinder_output(mod$pathfinder(data = data_file_r, init = init_function)) +}) + test_that("pathfinder() method runs when all arguments specified", { expect_pathfinder_output(fit <- do.call(mod$pathfinder, ok_arg_values)) expect_is(fit, "CmdStanPathfinder")