Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
IP
elsa
Commits
583f576a
Commit
583f576a
authored
Apr 24, 2022
by
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
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
elsa/core/Utilities/Math.hpp
View file @
583f576a
...
...
@@ -70,7 +70,7 @@ namespace elsa
data_t
meanSquaredError
(
DataContainer
<
data_t
>
dc1
,
DataContainer
<
data_t
>
dc2
)
{
if
(
dc1
.
getDataDescriptor
()
!=
dc2
.
getDataDescriptor
())
{
throw
Logic
Error
(
throw
InvalidArgument
Error
(
"Statistics::meanSquaredError: shapes of both signals should match"
);
}
...
...
elsa/core/tests/test_Math.cpp
View file @
583f576a
...
...
@@ -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"
)
...
...
elsa/test_allmodules/TestDriver.h
View file @
583f576a
...
...
@@ -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
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment