Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
ea636e14
Commit
ea636e14
authored
9 years ago
by
Raquel Alvarez Banos
Browse files
Options
Downloads
Patches
Plain Diff
Re #13952 Added two tests to test period subtraction
parent
dd40f84f
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Framework/WorkflowAlgorithms/test/MuonCalculateAsymmetryTest.h
+100
-2
100 additions, 2 deletions
...work/WorkflowAlgorithms/test/MuonCalculateAsymmetryTest.h
with
100 additions
and
2 deletions
Framework/WorkflowAlgorithms/test/MuonCalculateAsymmetryTest.h
+
100
−
2
View file @
ea636e14
...
...
@@ -171,7 +171,7 @@ public:
AnalysisDataService
::
Instance
().
remove
(
outWSName
);
}
void
test_groupAsymmetry
()
{
void
test_groupAsymmetry
_singlePeriod
()
{
// Name of the output workspace.
const
std
::
string
outWSName
=
outputWorkspaceName
(
"GroupAsymmetry"
);
...
...
@@ -213,7 +213,56 @@ public:
AnalysisDataService
::
Instance
().
remove
(
outWSName
);
}
void
test_pairAsymmetry
()
{
void
test_groupAsymmetry_twoPeriods_minus
()
{
// Name of the output workspace.
const
std
::
string
outWSName
=
outputWorkspaceName
(
"GroupAsymmetry"
);
MatrixWorkspace_sptr
inWS
=
createWorkspace
(
3
);
MatrixWorkspace_sptr
inWSSecond
=
createWorkspace
();
MuonCalculateAsymmetry
alg
;
alg
.
initialize
();
alg
.
setProperty
(
"FirstPeriodWorkspace"
,
inWS
);
alg
.
setProperty
(
"SecondPeriodWorkspace"
,
inWSSecond
);
alg
.
setProperty
(
"PeriodOperation"
,
"-"
);
alg
.
setProperty
(
"OutputType"
,
"GroupAsymmetry"
);
alg
.
setProperty
(
"GroupIndex"
,
2
);
alg
.
setPropertyValue
(
"OutputWorkspace"
,
outWSName
);
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
(););
TS_ASSERT
(
alg
.
isExecuted
());
// Retrieve the workspace from data service.
auto
ws
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
outWSName
);
TS_ASSERT
(
ws
);
if
(
ws
)
{
TS_ASSERT_EQUALS
(
ws
->
getNumberHistograms
(),
1
);
TS_ASSERT_EQUALS
(
ws
->
blocksize
(),
3
);
TS_ASSERT_EQUALS
(
ws
->
readX
(
0
)[
0
],
1
);
TS_ASSERT_EQUALS
(
ws
->
readX
(
0
)[
1
],
2
);
TS_ASSERT_EQUALS
(
ws
->
readX
(
0
)[
2
],
3
);
TS_ASSERT_DELTA
(
ws
->
readY
(
0
)[
0
],
0.0030
,
0.0001
);
TS_ASSERT_DELTA
(
ws
->
readY
(
0
)[
1
],
-
0.0455
,
0.0001
);
TS_ASSERT_DELTA
(
ws
->
readY
(
0
)[
2
],
-
0.1511
,
0.0001
);
TS_ASSERT_DELTA
(
ws
->
readE
(
0
)[
0
],
0.1066
,
0.0001
);
TS_ASSERT_DELTA
(
ws
->
readE
(
0
)[
1
],
0.1885
,
0.0001
);
TS_ASSERT_DELTA
(
ws
->
readE
(
0
)[
2
],
0.3295
,
0.0001
);
}
// Remove workspace from the data service.
AnalysisDataService
::
Instance
().
remove
(
outWSName
);
}
void
test_groupAsymmetry_twoPeriods_plus
()
{
// TODO: write test once plus operation is fixed
}
void
test_pairAsymmetry_singlePeriod
()
{
// Name of the output workspace.
const
std
::
string
outWSName
=
outputWorkspaceName
(
"GroupAsymmetry"
);
...
...
@@ -257,6 +306,55 @@ public:
AnalysisDataService
::
Instance
().
remove
(
outWSName
);
}
void
test_pairAsymmetry_twoPeriods_minus
()
{
// Name of the output workspace.
const
std
::
string
outWSName
=
outputWorkspaceName
(
"GroupAsymmetry"
);
MatrixWorkspace_sptr
inWS
=
createWorkspace
(
3
);
MatrixWorkspace_sptr
inWSSecond
=
createWorkspace
();
MuonCalculateAsymmetry
alg
;
alg
.
initialize
();
alg
.
setProperty
(
"FirstPeriodWorkspace"
,
inWS
);
alg
.
setProperty
(
"SecondPeriodWorkspace"
,
inWSSecond
);
alg
.
setProperty
(
"OutputType"
,
"PairAsymmetry"
);
alg
.
setProperty
(
"PairFirstIndex"
,
2
);
alg
.
setProperty
(
"PairSecondIndex"
,
0
);
alg
.
setPropertyValue
(
"OutputWorkspace"
,
outWSName
);
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT
(
alg
.
isExecuted
());
// Retrieve the workspace from data service.
auto
ws
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
outWSName
);
TS_ASSERT
(
ws
);
if
(
ws
)
{
TS_ASSERT_EQUALS
(
ws
->
getNumberHistograms
(),
1
);
TS_ASSERT_EQUALS
(
ws
->
blocksize
(),
3
);
TS_ASSERT_DELTA
(
ws
->
readY
(
0
)[
0
],
1.1785
,
0.0001
);
TS_ASSERT_DELTA
(
ws
->
readY
(
0
)[
1
],
0.9750
,
0.0001
);
TS_ASSERT_DELTA
(
ws
->
readY
(
0
)[
2
],
0.8333
,
0.0001
);
TS_ASSERT_EQUALS
(
ws
->
readX
(
0
)[
0
],
1.5
);
TS_ASSERT_EQUALS
(
ws
->
readX
(
0
)[
1
],
2.5
);
TS_ASSERT_EQUALS
(
ws
->
readX
(
0
)[
2
],
3
);
TS_ASSERT_DELTA
(
ws
->
readE
(
0
)[
0
],
0.5290
,
0.001
);
TS_ASSERT_DELTA
(
ws
->
readE
(
0
)[
1
],
0.4552
,
0.001
);
TS_ASSERT_DELTA
(
ws
->
readE
(
0
)[
2
],
0.4073
,
0.001
);
}
// Remove workspace from the data service.
AnalysisDataService
::
Instance
().
remove
(
outWSName
);
}
void
test_pairAsymmetry_twoPeriods_plus
()
{
// TODO: write unit test for "+" operation once it is fixed
}
private
:
std
::
string
outputWorkspaceName
(
std
::
string
testName
)
{
return
"MuonCalculateAsymmetryTest_"
+
testName
+
"_OutputWS"
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment