Skip to content

Commit 8f82d77

Browse files
committed
[Jenkins] auto-formatting by clang-format version 6.0.1-14 (tags/RELEASE_601/final)
1 parent a0668d9 commit 8f82d77

16 files changed

+1173
-1222
lines changed

src/cmdstan/cli.hpp

Lines changed: 552 additions & 510 deletions
Large diffs are not rendered by default.

src/cmdstan/command/diagnose.hpp

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,53 +25,50 @@
2525

2626
namespace cmdstan {
2727

28-
int diagnose(CLI::App& app,
29-
SharedOptions& shared_options,
30-
DiagnoseOptions& diagnose_options) {
31-
stan::callbacks::stream_writer info(std::cout);
32-
stan::callbacks::stream_writer err(std::cout);
33-
stan::callbacks::stream_logger logger(std::cout, std::cout, std::cout,
34-
std::cerr, std::cerr);
28+
int diagnose(CLI::App& app, SharedOptions& shared_options,
29+
DiagnoseOptions& diagnose_options) {
30+
stan::callbacks::stream_writer info(std::cout);
31+
stan::callbacks::stream_writer err(std::cout);
32+
stan::callbacks::stream_logger logger(std::cout, std::cout, std::cout,
33+
std::cerr, std::cerr);
3534

36-
// Read arguments
37-
write_parallel_info(info);
38-
write_opencl_device(info);
39-
info();
35+
// Read arguments
36+
write_parallel_info(info);
37+
write_opencl_device(info);
38+
info();
4039

41-
stan::callbacks::writer init_writer;
42-
stan::callbacks::interrupt interrupt;
40+
stan::callbacks::writer init_writer;
41+
stan::callbacks::interrupt interrupt;
4342

44-
std::fstream output_stream(shared_options.output_file.c_str(),
45-
std::fstream::out);
46-
stan::callbacks::stream_writer sample_writer(output_stream, "# ");
43+
std::fstream output_stream(shared_options.output_file.c_str(),
44+
std::fstream::out);
45+
stan::callbacks::stream_writer sample_writer(output_stream, "# ");
4746

48-
//////////////////////////////////////////////////
49-
// Initialize Model //
50-
//////////////////////////////////////////////////
47+
//////////////////////////////////////////////////
48+
// Initialize Model //
49+
//////////////////////////////////////////////////
5150

52-
std::shared_ptr<stan::io::var_context> var_context
51+
std::shared_ptr<stan::io::var_context> var_context
5352
= get_var_context(shared_options.data_file);
5453

55-
stan::model::model_base &model
54+
stan::model::model_base& model
5655
= new_model(*var_context, shared_options.seed, &std::cout);
5756

58-
write_stan(sample_writer);
59-
write_model(sample_writer, model.model_name());
60-
print_old_command_header(app, shared_options, diagnose_options, sample_writer);
61-
write_parallel_info(sample_writer);
62-
write_opencl_device(sample_writer);
57+
write_stan(sample_writer);
58+
write_model(sample_writer, model.model_name());
59+
print_old_command_header(app, shared_options, diagnose_options,
60+
sample_writer);
61+
write_parallel_info(sample_writer);
62+
write_opencl_device(sample_writer);
6363

64-
std::shared_ptr<stan::io::var_context> init_context = get_var_context(shared_options.init_file);
64+
std::shared_ptr<stan::io::var_context> init_context
65+
= get_var_context(shared_options.init_file);
6566

66-
return stan::services::diagnose
67-
::diagnose(model, *init_context,
68-
shared_options.seed,
69-
shared_options.id,
70-
shared_options.init_radius,
71-
diagnose_options.epsilon,
72-
diagnose_options.threshold,
73-
interrupt, logger, init_writer,
74-
sample_writer);
75-
}
67+
return stan::services::diagnose ::diagnose(
68+
model, *init_context, shared_options.seed, shared_options.id,
69+
shared_options.init_radius, diagnose_options.epsilon,
70+
diagnose_options.threshold, interrupt, logger, init_writer,
71+
sample_writer);
72+
}
7673
} // namespace cmdstan
7774
#endif

src/cmdstan/command/generate_quantities.hpp

Lines changed: 74 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -25,106 +25,98 @@
2525

2626
namespace cmdstan {
2727

28-
int generate_quantities(CLI::App& app,
29-
SharedOptions& shared_options,
30-
GenerateQuantitiesOptions& gq_options) {
31-
static int hmc_fixed_cols = 7; // hmc sampler outputs columns __lp + 6
28+
int generate_quantities(CLI::App& app, SharedOptions& shared_options,
29+
GenerateQuantitiesOptions& gq_options) {
30+
static int hmc_fixed_cols = 7; // hmc sampler outputs columns __lp + 6
3231

33-
stan::callbacks::stream_writer info(std::cout);
34-
stan::callbacks::stream_writer err(std::cout);
35-
stan::callbacks::stream_logger logger(std::cout, std::cout, std::cout,
36-
std::cerr, std::cerr);
32+
stan::callbacks::stream_writer info(std::cout);
33+
stan::callbacks::stream_writer err(std::cout);
34+
stan::callbacks::stream_logger logger(std::cout, std::cout, std::cout,
35+
std::cerr, std::cerr);
3736

38-
// Read arguments
39-
write_parallel_info(info);
40-
write_opencl_device(info);
41-
info();
37+
// Read arguments
38+
write_parallel_info(info);
39+
write_opencl_device(info);
40+
info();
4241

43-
if (gq_options.fitted_params == shared_options.output_file) {
44-
std::stringstream msg;
45-
msg << "Filename conflict, fitted_params file "
46-
<< gq_options.fitted_params
47-
<< " and output file have same name, must be different."
48-
<< std::endl;
49-
throw std::invalid_argument(msg.str());
50-
}
42+
if (gq_options.fitted_params == shared_options.output_file) {
43+
std::stringstream msg;
44+
msg << "Filename conflict, fitted_params file " << gq_options.fitted_params
45+
<< " and output file have same name, must be different." << std::endl;
46+
throw std::invalid_argument(msg.str());
47+
}
5148

52-
stan::callbacks::interrupt interrupt;
49+
stan::callbacks::interrupt interrupt;
5350

54-
std::fstream output_stream(shared_options.output_file.c_str(),
55-
std::fstream::out);
56-
stan::callbacks::stream_writer sample_writer(output_stream, "# ");
51+
std::fstream output_stream(shared_options.output_file.c_str(),
52+
std::fstream::out);
53+
stan::callbacks::stream_writer sample_writer(output_stream, "# ");
5754

58-
//////////////////////////////////////////////////
59-
// Initialize Model //
60-
//////////////////////////////////////////////////
55+
//////////////////////////////////////////////////
56+
// Initialize Model //
57+
//////////////////////////////////////////////////
6158

62-
std::shared_ptr<stan::io::var_context> var_context
59+
std::shared_ptr<stan::io::var_context> var_context
6360
= get_var_context(shared_options.data_file);
6461

65-
stan::model::model_base &model
62+
stan::model::model_base& model
6663
= new_model(*var_context, shared_options.seed, &std::cout);
6764

68-
write_stan(sample_writer);
69-
write_model(sample_writer, model.model_name());
70-
print_old_command_header(app, shared_options, gq_options, sample_writer);
71-
write_parallel_info(sample_writer);
72-
write_opencl_device(sample_writer);
73-
74-
std::ifstream stream(gq_options.fitted_params.c_str());
75-
if (stream.rdstate() & std::ifstream::failbit) {
76-
std::stringstream msg;
77-
msg << "Can't open specified file, \""
78-
<< gq_options.fitted_params << "\""
79-
<< std::endl;
80-
throw std::invalid_argument(msg.str());
81-
}
65+
write_stan(sample_writer);
66+
write_model(sample_writer, model.model_name());
67+
print_old_command_header(app, shared_options, gq_options, sample_writer);
68+
write_parallel_info(sample_writer);
69+
write_opencl_device(sample_writer);
8270

83-
stan::io::stan_csv fitted_params;
71+
std::ifstream stream(gq_options.fitted_params.c_str());
72+
if (stream.rdstate() & std::ifstream::failbit) {
8473
std::stringstream msg;
85-
stan::io::stan_csv_reader
86-
::read_metadata(stream, fitted_params.metadata, &msg);
87-
if (!stan::io::stan_csv_reader
88-
::read_header(stream, fitted_params.header,
89-
&msg, false)) {
90-
msg << "Error reading fitted param names from sample csv file \""
91-
<< gq_options.fitted_params << "\"" << std::endl;
92-
throw std::invalid_argument(msg.str());
93-
}
94-
stan::io::stan_csv_reader
95-
::read_adaptation(stream, fitted_params.adaptation, &msg);
96-
fitted_params.timing.warmup = 0;
97-
fitted_params.timing.sampling = 0;
98-
stan::io::stan_csv_reader::read_samples(stream,
99-
fitted_params.samples,
100-
fitted_params.timing, &msg);
101-
stream.close();
74+
msg << "Can't open specified file, \"" << gq_options.fitted_params << "\""
75+
<< std::endl;
76+
throw std::invalid_argument(msg.str());
77+
}
78+
79+
stan::io::stan_csv fitted_params;
80+
std::stringstream msg;
81+
stan::io::stan_csv_reader ::read_metadata(stream, fitted_params.metadata,
82+
&msg);
83+
if (!stan::io::stan_csv_reader ::read_header(stream, fitted_params.header,
84+
&msg, false)) {
85+
msg << "Error reading fitted param names from sample csv file \""
86+
<< gq_options.fitted_params << "\"" << std::endl;
87+
throw std::invalid_argument(msg.str());
88+
}
89+
stan::io::stan_csv_reader ::read_adaptation(stream, fitted_params.adaptation,
90+
&msg);
91+
fitted_params.timing.warmup = 0;
92+
fitted_params.timing.sampling = 0;
93+
stan::io::stan_csv_reader::read_samples(stream, fitted_params.samples,
94+
fitted_params.timing, &msg);
95+
stream.close();
10296

103-
std::vector<std::string> param_names;
104-
model.constrained_param_names(param_names, false, false);
105-
size_t num_cols = param_names.size();
106-
size_t num_rows = fitted_params.metadata.num_samples;
107-
// check that all parameter names are in sample, in order
108-
if (num_cols + hmc_fixed_cols > fitted_params.header.size()) {
97+
std::vector<std::string> param_names;
98+
model.constrained_param_names(param_names, false, false);
99+
size_t num_cols = param_names.size();
100+
size_t num_rows = fitted_params.metadata.num_samples;
101+
// check that all parameter names are in sample, in order
102+
if (num_cols + hmc_fixed_cols > fitted_params.header.size()) {
103+
std::stringstream msg;
104+
msg << "Mismatch between model and fitted_parameters csv file \""
105+
<< gq_options.fitted_params << "\"" << std::endl;
106+
throw std::invalid_argument(msg.str());
107+
}
108+
for (size_t i = 0; i < num_cols; ++i) {
109+
if (param_names[i].compare(fitted_params.header[i + hmc_fixed_cols]) != 0) {
109110
std::stringstream msg;
110111
msg << "Mismatch between model and fitted_parameters csv file \""
111-
<< gq_options.fitted_params << "\"" << std::endl;
112+
<< gq_options.fitted_params << "\"" << std::endl;
112113
throw std::invalid_argument(msg.str());
113114
}
114-
for (size_t i = 0; i < num_cols; ++i) {
115-
if (param_names[i].compare(fitted_params.header[i + hmc_fixed_cols])
116-
!= 0) {
117-
std::stringstream msg;
118-
msg << "Mismatch between model and fitted_parameters csv file \""
119-
<< gq_options.fitted_params << "\"" << std::endl;
120-
throw std::invalid_argument(msg.str());
121-
}
122-
}
123-
return stan::services
124-
::standalone_generate(model,
125-
fitted_params.samples.block(0, hmc_fixed_cols, num_rows, num_cols),
126-
shared_options.seed, interrupt, logger, sample_writer);
127-
return stan::services::error_codes::CONFIG;
128115
}
116+
return stan::services ::standalone_generate(
117+
model, fitted_params.samples.block(0, hmc_fixed_cols, num_rows, num_cols),
118+
shared_options.seed, interrupt, logger, sample_writer);
119+
return stan::services::error_codes::CONFIG;
120+
}
129121
} // namespace cmdstan
130122
#endif

0 commit comments

Comments
 (0)