Skip to content

Commit

Permalink
Merge f30e08b into e794a63
Browse files Browse the repository at this point in the history
  • Loading branch information
umangyadav committed Jun 23, 2023
2 parents e794a63 + f30e08b commit 9dc50b6
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,31 @@ std::string classify(T x)
}
}

void print_statistics(std::ostream& os, const argument& a)

Check warning on line 362 in src/program.cpp

View check run for this annotation

Codecov / codecov/patch

src/program.cpp#L362

Added line #L362 was not covered by tests
{
a.visit(
[&](auto t) {
os << "Min value: " << *std::min_element(t.begin(), t.end()) << ", ";
os << "Max value: " << *std::max_element(t.begin(), t.end()) << ", ";
double num_elements = t.size();
auto mean = std::reduce(t.begin(), t.end(), 0.0) / num_elements;
auto stddev = std::sqrt(
std::accumulate(t.begin(),

Check warning on line 371 in src/program.cpp

View check run for this annotation

Codecov / codecov/patch

src/program.cpp#L364-L371

Added lines #L364 - L371 were not covered by tests
t.end(),
0.0,
[&](auto r, auto v) { return r + std::pow((v - mean), 2.0); }) /

Check warning on line 374 in src/program.cpp

View check run for this annotation

Codecov / codecov/patch

src/program.cpp#L374

Added line #L374 was not covered by tests
num_elements);
os << "Mean: " << mean << ", ";
os << "StdDev: " << stddev << "\n";
},
[&](const auto& xs) {
for(const auto& x : xs)

Check warning on line 380 in src/program.cpp

View check run for this annotation

Codecov / codecov/patch

src/program.cpp#L376-L380

Added lines #L376 - L380 were not covered by tests
{
print_statistics(os, x);

Check warning on line 382 in src/program.cpp

View check run for this annotation

Codecov / codecov/patch

src/program.cpp#L382

Added line #L382 was not covered by tests
}
});
}

Check warning on line 385 in src/program.cpp

View check run for this annotation

Codecov / codecov/patch

src/program.cpp#L384-L385

Added lines #L384 - L385 were not covered by tests

std::unordered_set<std::string> classify_argument(const argument& a)
{
std::unordered_set<std::string> result;
Expand Down Expand Up @@ -578,6 +603,7 @@ std::vector<argument> program::eval(parameter_map params, execution_environment
std::cout << "Output: ";
preview_argument(std::cout, buffer);
std::cout << std::endl;
print_statistics(std::cout, buffer);

Check warning on line 606 in src/program.cpp

View check run for this annotation

Codecov / codecov/patch

src/program.cpp#L606

Added line #L606 was not covered by tests
}
else
{
Expand Down

0 comments on commit 9dc50b6

Please sign in to comment.