Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions src/cmdstan/command.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,23 +563,17 @@ int command(int argc, const char *argv[]) {
list_argument *algo = dynamic_cast<list_argument *>(
parser.arg("method")->arg("sample")->arg("algorithm"));
std::string algo_name = algo->value();
bool use_fixed_param
= model.num_params_r() == 0 || algo_name == "fixed_param";

bool adapt_engaged = get_arg_val<bool_argument>(parser, "method", "sample",
"adapt", "engaged");
if (!use_fixed_param && adapt_engaged == true && num_warmup == 0) {
if (algo_name != "fixed_param" && adapt_engaged == true
&& num_warmup == 0) {
msg << "The number of warmup samples (num_warmup) must be greater than "
<< "zero if adaptation is enabled." << std::endl;
throw std::invalid_argument(msg.str());
}

if (use_fixed_param) {
if (algo_name != "fixed_param") {
info(
"Model contains no parameters, running fixed_param sampler, "
"no updates to Markov chain");
}
if (algo_name == "fixed_param") {
return_code = stan::services::sample::fixed_param(
model, num_chains, init_contexts, random_seed, id, init_radius,
num_samples, num_thin, refresh, interrupt, logger, init_writers,
Expand Down
6 changes: 1 addition & 5 deletions src/test/interface/fixed_param_sampler_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ TEST(McmcFixedParamSampler, check_empty) {
EXPECT_EQ(success, true);
}

TEST(McmcFixedParamSampler, check_empty_but_algorithm_not_fixed_param) {
TEST(McmcFixedParamSampler, check_empty_not_fixed_param) {
std::vector<std::string> model_path;
model_path.push_back("src");
model_path.push_back("test");
Expand All @@ -88,8 +88,4 @@ TEST(McmcFixedParamSampler, check_empty_but_algorithm_not_fixed_param) {
}

EXPECT_EQ(success, true);
std::string expected_message
= "Model contains no parameters, running fixed_param sampler";
EXPECT_TRUE(
boost::algorithm::contains(command_output.output, expected_message));
}