Skip to content

Commit

Permalink
Merge pull request #964 from stan-dev/pathfinder-init-funs
Browse files Browse the repository at this point in the history
Pathfinder method errors with init function due to NULL default num_paths
  • Loading branch information
andrjohns authored May 7, 2024
2 parents 21888fa + 0c2179e commit c3d0168
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion man/model-method-pathfinder.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/testthat/test-model-pathfinder.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit c3d0168

Please sign in to comment.