Skip to content

Commit c3d0168

Browse files
authored
Merge pull request #964 from stan-dev/pathfinder-init-funs
Pathfinder method errors with init function due to NULL default num_paths
2 parents 21888fa + 0c2179e commit c3d0168

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

R/model.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,7 @@ pathfinder <- function(data = NULL,
19391939
history_size = NULL,
19401940
single_path_draws = NULL,
19411941
draws = NULL,
1942-
num_paths = NULL,
1942+
num_paths = 4,
19431943
max_lbfgs_iters = NULL,
19441944
num_elbo_draws = NULL,
19451945
save_single_paths = NULL,

man/model-method-pathfinder.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-model-pathfinder.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ test_that("pathfinder() method works with init file", {
124124
expect_pathfinder_output(mod$pathfinder(data = data_file_r, init = init_file))
125125
})
126126

127+
test_that("pathfinder() method works with init function and default paths", {
128+
init_function <- function() { list(theta = 0.5) }
129+
expect_pathfinder_output(mod$pathfinder(data = data_file_r, init = init_function))
130+
})
131+
127132
test_that("pathfinder() method runs when all arguments specified", {
128133
expect_pathfinder_output(fit <- do.call(mod$pathfinder, ok_arg_values))
129134
expect_is(fit, "CmdStanPathfinder")

0 commit comments

Comments
 (0)