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
2 changes: 1 addition & 1 deletion cpp/memilio/utils/time_series.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ class TimeSeries
// Note: input manipulators (like std::setw, std::left) are consumed by the first argument written to the stream
// print column labels
const auto w = width, p = precision;
set_ostream_format(out, w, p) << std::left << "Time";
set_ostream_format(out, w, p) << std::left << "\nTime";
for (size_t k = 0; k < static_cast<size_t>(get_num_elements()); k++) {
if (k < column_labels.size()) {
out << " ";
Expand Down
6 changes: 3 additions & 3 deletions cpp/tests/test_time_series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,21 +335,21 @@ TYPED_TEST(TestTimeSeries, print_table)
ts.get_time((Eigen::Index)0) = 0.0;
ts.get_time((Eigen::Index)1) = 1.0;

std::string expected_output_1 = "Time col_1 col_2\n0.00 0.12 1.12\n1.00 1.12 2.12\n";
std::string expected_output_1 = "\nTime col_1 col_2\n0.00 0.12 1.12\n1.00 1.12 2.12\n";
ts.print_table({"col_1", "col_2"}, 4, 2, output);
std::string actual_output_1 = output.str();
EXPECT_EQ(expected_output_1, actual_output_1);

output.str("");

std::string expected_output_2 = "Time #1 #2 \n 0.0 0.1 1.1\n 1.0 1.1 2.1\n";
std::string expected_output_2 = "\nTime #1 #2 \n 0.0 0.1 1.1\n 1.0 1.1 2.1\n";
ts.print_table({}, 6, 1, output);
std::string actual_output_2 = output.str();
EXPECT_EQ(expected_output_2, actual_output_2);

output.str("");

std::string expected_output_3 = "Time col_1 #2 \n 0.0000 0.1235 "
std::string expected_output_3 = "\nTime col_1 #2 \n 0.0000 0.1235 "
"1.1235\n 1.0000 1.1235 2.1235\n";
ts.print_table({"col_1"}, 12, 4, output);
std::string actual_output_3 = output.str();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_print_table(self):
ts.add_time_point(3.5, np.r_[2])
output = ts.print_table(["a", "b"], 2, 2)
self.assertEqual(
output, 'Time a \n2.00 1.00\n3.50 2.00\n')
output, '\nTime a \n2.00 1.00\n3.50 2.00\n')


if __name__ == '__main__':
Expand Down