Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/fix/init-err-msgs' …
Browse files Browse the repository at this point in the history
…into fix/init-err-msgs
  • Loading branch information
SteveBronder committed May 28, 2024
2 parents 0d2b276 + 7f42c01 commit aa55328
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/stan/services/util/initialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ std::vector<double> initialize(Model& model, const InitContext& init, RNG& rng,
std::stringstream msg;
msg << "Partial user-specified initialization failed. "
"Initialization of non user specified parameters "
"between (-" << init_radius << ", " << init_radius
<< ") failed after"
"between (-"
<< init_radius << ", " << init_radius << ") failed after"
<< " " << MAX_INIT_TRIES << " attempts. ";
logger.error(msg);
logger.error(
Expand All @@ -255,7 +255,6 @@ std::vector<double> initialize(Model& model, const InitContext& init, RNG& rng,
" Try specifying initial values,"
" reducing ranges of constrained values,"
" or reparameterizing the model.");

}
throw std::domain_error("Initialization failed.");
}
Expand Down
6 changes: 4 additions & 2 deletions src/test/unit/services/instrumented_callbacks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,12 @@ class instrumented_logger : public stan::callbacks::logger {
count++;
return count;
}
public:

public:
std::vector<std::string> return_all_logs() {
std::vector<std::string> all_logs;
all_logs.reserve(debug_.size() + info_.size() + warn_.size() + error_.size() + fatal_.size() + 5);
all_logs.reserve(debug_.size() + info_.size() + warn_.size() + error_.size()
+ fatal_.size() + 5);
all_logs.emplace_back("DEBUG");
all_logs.insert(all_logs.end(), debug_.begin(), debug_.end());
all_logs.emplace_back("INFO");
Expand Down
4 changes: 2 additions & 2 deletions src/test/unit/services/util/fail_init_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ TEST_F(ServicesUtilInitialize, model_throws__full_init) {
double init_radius = 2;
bool print_timing = false;
EXPECT_THROW(
stan::services::util::initialize(model, init_context, rng,
init_radius, print_timing, logger, init),
stan::services::util::initialize(model, init_context, rng, init_radius,
print_timing, logger, init),
std::domain_error);
/* Uncomment to print all logs
auto logs = logger.return_all_logs();
Expand Down

0 comments on commit aa55328

Please sign in to comment.