Skip to content

Commit

Permalink
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-buildbot committed Feb 4, 2025
1 parent 38d99aa commit 098c655
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
13 changes: 6 additions & 7 deletions src/stan/callbacks/stream_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class stream_writer : public writer {
output_ << comment_prefix_ << message << std::endl;
}

/**
/**
* Writes multiple rows and columns of values in csv format.
*
* Note: the precision of the output is determined by the settings
Expand All @@ -90,8 +90,8 @@ class stream_writer : public writer {
* @param[in] values A column vector of values.
*/
virtual void operator()(const Eigen::Matrix<double, -1, 1>& values) {
output_ << values.transpose().format(CommaInitFmt);
}
output_ << values.transpose().format(CommaInitFmt);
}

/**
* Write a row of values in csv format
Expand All @@ -102,17 +102,16 @@ class stream_writer : public writer {
* @param[in] values A row vector of values.
*/
virtual void operator()(const Eigen::Matrix<double, 1, -1>& values) {
output_ << values.format(CommaInitFmt);
}

output_ << values.format(CommaInitFmt);
}

/**
* Checks if stream is valid.
*/
virtual bool is_valid() const noexcept { return output_.good(); }

private:
/**
/**
* Comma formatter for writing Eigen matrices
*/
Eigen::IOFormat CommaInitFmt{
Expand Down
17 changes: 8 additions & 9 deletions src/stan/callbacks/unique_stream_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ class unique_stream_writer final : public writer {
* @param[in] values A column vector of values.
*/
virtual void operator()(const Eigen::Matrix<double, -1, 1>& values) {
if (output_ == nullptr) {
return;
}
*output_ << values.transpose().format(CommaInitFmt);
if (output_ == nullptr) {
return;
}
*output_ << values.transpose().format(CommaInitFmt);
}

/**
* Write a row of values in csv format
Expand All @@ -118,12 +118,11 @@ class unique_stream_writer final : public writer {
* @param[in] values A row vector of values.
*/
virtual void operator()(const Eigen::Matrix<double, 1, -1>& values) {
if (output_ == nullptr) {
return;
}
*output_ << values.format(CommaInitFmt);
if (output_ == nullptr) {
return;
}

*output_ << values.format(CommaInitFmt);
}

/**
* Writes the comment_prefix to the stream followed by a newline.
Expand Down
9 changes: 3 additions & 6 deletions src/stan/callbacks/writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ class writer {
* parameters in the rows and samples in the columns. The matrix is then
* transposed for the output.
*/
virtual void operator()(
const Eigen::Matrix<double, -1, -1>& values) {}
virtual void operator()(const Eigen::Matrix<double, -1, -1>& values) {}
/**
* Write a row of values in csv format.
*
Expand All @@ -71,8 +70,7 @@ class writer {
*
* @param[in] values A column vector of values.
*/
virtual void operator()(
const Eigen::Matrix<double, -1, 1>& values) {}
virtual void operator()(const Eigen::Matrix<double, -1, 1>& values) {}

/**
* Write a row of values in csv format
Expand All @@ -82,8 +80,7 @@ class writer {
*
* @param[in] values A row vector of values.
*/
virtual void operator()(
const Eigen::Matrix<double, 1, -1>& values) {}
virtual void operator()(const Eigen::Matrix<double, 1, -1>& values) {}
};

} // namespace callbacks
Expand Down
13 changes: 8 additions & 5 deletions src/test/unit/services/pathfinder/eight_schools_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,14 @@ TEST_F(ServicesPathfinderEightSchools, multi_output) {
constexpr bool resample = true;
std::unique_ptr<std::ostream> empty_ostream(nullptr);
stan::test::test_logger logger(std::move(empty_ostream));
using unique_string_writer = stan::callbacks::unique_stream_writer<std::stringstream>;
using unique_string_writer
= stan::callbacks::unique_stream_writer<std::stringstream>;
std::vector<unique_string_writer> single_path_parameter_writer;
unique_string_writer parameter_writer{std::make_unique<std::stringstream>(), "# "};
unique_string_writer parameter_writer{std::make_unique<std::stringstream>(),
"# "};
for (int i = 0; i < num_paths; ++i) {
single_path_parameter_writer.emplace_back(std::make_unique<std::stringstream>(), "# ");
single_path_parameter_writer.emplace_back(
std::make_unique<std::stringstream>(), "# ");
}
std::vector<stan::callbacks::json_writer<std::stringstream>>
single_path_diagnostic_writer(num_paths);
Expand All @@ -188,8 +191,8 @@ TEST_F(ServicesPathfinderEightSchools, multi_output) {
num_iterations, num_elbo_draws, num_draws, num_multi_draws, num_paths,
save_iterations, refresh, callback, logger,
std::vector<stan::callbacks::stream_writer>(num_paths, init),
single_path_parameter_writer, single_path_diagnostic_writer, parameter_writer,
diagnostics, calculate_lp, resample);
single_path_parameter_writer, single_path_diagnostic_writer,
parameter_writer, diagnostics, calculate_lp, resample);

auto str = parameter_writer.get_stream().str();
{
Expand Down

0 comments on commit 098c655

Please sign in to comment.