Skip to content

Commit 5c0b7b2

Browse files
authored
Merge pull request #1190 from stan-dev/bugfix/1189-pathfinder-diagnostics
Bugfix/1189 pathfinder diagnostics
2 parents 763beb9 + ed81877 commit 5c0b7b2

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/cmdstan/command.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ int command(int argc, const char *argv[]) {
259259
= get_arg_val<bool_argument>(*pathfinder_arg, "save_single_paths");
260260

261261
if (num_paths == 1) {
262+
if (!get_arg_val<string_argument>(parser, "output", "diagnostic_file")
263+
.empty()) {
264+
save_iterations = true;
265+
}
262266
return_code = stan::services::pathfinder::pathfinder_lbfgs_single<
263267
false, stan::model::model_base>(
264268
model, *(init_contexts[0]), random_seed, id, init_radius,

src/test/interface/pathfinder_test.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,22 @@ TEST_F(CmdStan, pathfinder_save_single_num_paths_1_diag_file_arg) {
175175
ASSERT_FALSE(file_exists(convert_model_path(output_single_json)));
176176
}
177177

178+
TEST_F(CmdStan, pathfinder_save_single_num_paths_0_diag_file_arg) {
179+
std::stringstream ss;
180+
ss << convert_model_path(multi_normal_model)
181+
<< " output refresh=0 file=" << convert_model_path(arg_output)
182+
<< " diagnostic_file=" << convert_model_path(arg_diags)
183+
<< " method=pathfinder"
184+
<< " num_paths=1 save_single_paths=0";
185+
run_command_output out = run_command(ss.str());
186+
ASSERT_FALSE(out.hasError);
187+
ASSERT_TRUE(file_exists(convert_model_path(output_csv)));
188+
ASSERT_TRUE(file_exists(convert_model_path(output_diags)));
189+
ASSERT_FALSE(file_exists(convert_model_path(output_json)));
190+
ASSERT_FALSE(file_exists(convert_model_path(output_single_csv)));
191+
ASSERT_FALSE(file_exists(convert_model_path(output_single_json)));
192+
}
193+
178194
TEST_F(CmdStan, pathfinder_num_paths_8) {
179195
std::stringstream ss;
180196
ss << convert_model_path(multi_normal_model)

0 commit comments

Comments
 (0)