Commit 583f576a authored by AndiBraimllari's avatar AndiBraimllari
Browse files

add tests for invalid arguments in some calls, specify namespace in TestDriver.h

parent aecc7900
Pipeline #879482 passed with stages
in 17 minutes and 6 seconds
......@@ -70,7 +70,7 @@ namespace elsa
data_t meanSquaredError(DataContainer<data_t> dc1, DataContainer<data_t> dc2)
{
if (dc1.getDataDescriptor() != dc2.getDataDescriptor()) {
throw LogicError(
throw InvalidArgumentError(
"Statistics::meanSquaredError: shapes of both signals should match");
}
......
......@@ -85,6 +85,13 @@ TEST_CASE_TEMPLATE("Math: Testing the statistics", TestType, float, double)
WHEN("running the Mean Squared Error")
{
DataContainer<TestType> dataCont3(VolumeDescriptor{{4, 3, 8}});
THEN("it throws if the containers have different shapes")
{
REQUIRE_THROWS_AS(statistics::meanSquaredError<TestType>(dataCont1, dataCont3),
InvalidArgumentError);
}
auto meanSqErr = statistics::meanSquaredError<TestType>(dataCont1, dataCont2);
THEN("it produces the correct result")
{
......@@ -94,6 +101,13 @@ TEST_CASE_TEMPLATE("Math: Testing the statistics", TestType, float, double)
WHEN("running the Relative Error")
{
DataContainer<TestType> dataCont3(VolumeDescriptor{{7, 6, 5, 4}});
THEN("it throws if the containers have different shapes")
{
REQUIRE_THROWS_AS(statistics::relativeError<TestType>(dataCont1, dataCont3),
InvalidArgumentError);
}
auto relErr = statistics::relativeError<TestType>(dataCont1, dataCont2);
THEN("it produces the correct result")
{
......@@ -103,6 +117,14 @@ TEST_CASE_TEMPLATE("Math: Testing the statistics", TestType, float, double)
WHEN("running the Peak Signal-to-Noise Ratio")
{
DataContainer<TestType> dataCont3(VolumeDescriptor{4});
THEN("it throws if the containers have different shapes")
{
REQUIRE_THROWS_AS(
statistics::peakSignalToNoiseRatio<TestType>(dataCont1, dataCont3),
InvalidArgumentError);
}
auto psnr = statistics::peakSignalToNoiseRatio<TestType>(dataCont1, dataCont2);
auto expectedpsnr = static_cast<TestType>(9.09461);
THEN("it produces the correct result")
......
......@@ -57,9 +57,9 @@ namespace elsa
relError.push_back(s._relError);
}
auto [timeMean, timeStddev] = calculateMeanStddev(time);
auto [absMean, absStddev] = calculateMeanStddev(absError);
auto [relMean, relStddev] = calculateMeanStddev(relError);
auto [timeMean, timeStddev] = statistics::calculateMeanStddev(time);
auto [absMean, absStddev] = statistics::calculateMeanStddev(absError);
auto [relMean, relStddev] = statistics::calculateMeanStddev(relError);
return std::make_tuple(timeMean, timeStddev, absMean, absStddev, relMean, relStddev);
}
......@@ -224,7 +224,8 @@ namespace elsa
auto [timeMean, timeStddev, absErrMean, absErrStddev, relErrMean, relErrStddev] =
evaluateStats(stats);
auto [lower, upper] = confidenceInterval95(benchIters, timeMean, timeStddev);
auto [lower, upper] =
statistics::confidenceInterval95(benchIters, timeMean, timeStddev);
// Log a laps
Logging::template logLaps<data_t>(dim, size, benchIters, opName, solName, noIters,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment