Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/1189 pathfinder diagnostics #1190

Merged
merged 9 commits into from
Aug 25, 2023
4 changes: 3 additions & 1 deletion src/cmdstan/command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ int command(int argc, const char *argv[]) {
= get_arg_val<int_argument>(*pathfinder_arg, "num_psis_draws");
int num_paths = get_arg_val<int_argument>(*pathfinder_arg, "num_paths");
bool save_iterations
= get_arg_val<bool_argument>(*pathfinder_arg, "save_single_paths");
= (get_arg_val<bool_argument>(*pathfinder_arg, "save_single_paths")
|| !get_arg_val<string_argument>(parser, "output", "diagnostic_file")
.empty());

if (num_paths == 1) {
return_code = stan::services::pathfinder::pathfinder_lbfgs_single<
Expand Down
16 changes: 16 additions & 0 deletions src/test/interface/pathfinder_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,22 @@ TEST_F(CmdStan, pathfinder_save_single_num_paths_1_diag_file_arg) {
ASSERT_FALSE(file_exists(convert_model_path(output_single_json)));
}

TEST_F(CmdStan, pathfinder_save_single_num_paths_0_diag_file_arg) {
std::stringstream ss;
ss << convert_model_path(multi_normal_model)
<< " output refresh=0 file=" << convert_model_path(arg_output)
<< " diagnostic_file=" << convert_model_path(arg_diags)
<< " method=pathfinder"
<< " num_paths=1 save_single_paths=0";
run_command_output out = run_command(ss.str());
ASSERT_FALSE(out.hasError);
ASSERT_TRUE(file_exists(convert_model_path(output_csv)));
ASSERT_TRUE(file_exists(convert_model_path(output_diags)));
ASSERT_FALSE(file_exists(convert_model_path(output_json)));
ASSERT_FALSE(file_exists(convert_model_path(output_single_csv)));
ASSERT_FALSE(file_exists(convert_model_path(output_single_json)));
}

TEST_F(CmdStan, pathfinder_num_paths_8) {
std::stringstream ss;
ss << convert_model_path(multi_normal_model)
Expand Down