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
61613c7e
Commit
61613c7e
authored
9 years ago
by
Elliot Oram
Committed by
Peterson, Peter
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add unit test for numerical axis data (_sqw data)
Refs #15250
parent
50944f07
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Framework/WorkflowAlgorithms/test/ConvolutionFitSequentialTest.h
+77
-4
77 additions, 4 deletions
...rk/WorkflowAlgorithms/test/ConvolutionFitSequentialTest.h
with
77 additions
and
4 deletions
Framework/WorkflowAlgorithms/test/ConvolutionFitSequentialTest.h
+
77
−
4
View file @
61613c7e
...
@@ -14,6 +14,8 @@
...
@@ -14,6 +14,8 @@
#include
"MantidTestHelpers/WorkspaceCreationHelper.h"
#include
"MantidTestHelpers/WorkspaceCreationHelper.h"
#include
<boost/assign/list_of.hpp>
using
Mantid
::
Algorithms
::
ConvolutionFitSequential
;
using
Mantid
::
Algorithms
::
ConvolutionFitSequential
;
using
namespace
Mantid
::
API
;
using
namespace
Mantid
::
API
;
using
namespace
Mantid
::
DataObjects
;
using
namespace
Mantid
::
DataObjects
;
...
@@ -118,11 +120,11 @@ public:
...
@@ -118,11 +120,11 @@ public:
}
}
//------------------------- Execution cases ---------------------------
//------------------------- Execution cases ---------------------------
void
test_exec
()
{
void
test_exec
_with_red_file
()
{
const
int
totalBins
=
6
;
const
int
totalBins
=
6
;
auto
resWs
=
create2DWorkspace
(
5
,
1
);
auto
resWs
=
create2DWorkspace
(
5
,
1
);
auto
redWs
=
create2DWorkspace
(
totalBins
,
5
);
auto
redWs
=
create2DWorkspace
(
totalBins
,
5
);
createConvitResWorkspace
(
5
,
totalBins
);
createConv
F
itResWorkspace
(
5
,
totalBins
);
AnalysisDataService
::
Instance
().
add
(
"ResolutionWs_"
,
resWs
);
AnalysisDataService
::
Instance
().
add
(
"ResolutionWs_"
,
resWs
);
AnalysisDataService
::
Instance
().
add
(
"ReductionWs_"
,
redWs
);
AnalysisDataService
::
Instance
().
add
(
"ReductionWs_"
,
redWs
);
Mantid
::
Algorithms
::
ConvolutionFitSequential
alg
;
Mantid
::
Algorithms
::
ConvolutionFitSequential
alg
;
...
@@ -143,7 +145,8 @@ public:
...
@@ -143,7 +145,8 @@ public:
alg
.
setProperty
(
"Convolve"
,
true
);
alg
.
setProperty
(
"Convolve"
,
true
);
alg
.
setProperty
(
"Minimizer"
,
"Levenberg-Marquardt"
);
alg
.
setProperty
(
"Minimizer"
,
"Levenberg-Marquardt"
);
alg
.
setProperty
(
"MaxIterations"
,
500
);
alg
.
setProperty
(
"MaxIterations"
,
500
);
alg
.
execute
();
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT
(
alg
.
isExecuted
());
// Retrieve and analyse parameter table - Param table does not require
// Retrieve and analyse parameter table - Param table does not require
// further testing as this is tested in the ProcessIndirectFitParameters
// further testing as this is tested in the ProcessIndirectFitParameters
...
@@ -193,10 +196,80 @@ public:
...
@@ -193,10 +196,80 @@ public:
TS_ASSERT_EQUALS
(
memberLogs
.
at
(
5
)
->
value
(),
"ConvFit"
);
TS_ASSERT_EQUALS
(
memberLogs
.
at
(
5
)
->
value
(),
"ConvFit"
);
TS_ASSERT_EQUALS
(
memberLogs
.
at
(
6
)
->
value
(),
"ReductionWs_"
);
TS_ASSERT_EQUALS
(
memberLogs
.
at
(
6
)
->
value
(),
"ReductionWs_"
);
TS_ASSERT_EQUALS
(
memberLogs
.
at
(
7
)
->
value
(),
"1"
);
TS_ASSERT_EQUALS
(
memberLogs
.
at
(
7
)
->
value
(),
"1"
);
AnalysisDataService
::
Instance
().
clear
();
}
void
test_exec_with_sqw_file
()
{
auto
sqwWs
=
createGenericWorkspace
(
"SqwWs_"
,
true
);
auto
resWs
=
createGenericWorkspace
(
"ResolutionWs_"
,
false
);
auto
convFitRes
=
createGenericWorkspace
(
"__ConvFit_Resolution"
,
false
);
Mantid
::
Algorithms
::
ConvolutionFitSequential
alg
;
TS_ASSERT_THROWS_NOTHING
(
alg
.
initialize
());
alg
.
setProperty
(
"InputWorkspace"
,
sqwWs
);
alg
.
setProperty
(
"Function"
,
"name=LinearBackground,A0=0,A1=0,ties=(A0=0.000000,A1=0.0);"
"(composite=Convolution,FixResolution=true,NumDeriv=true;"
"name=Resolution,Workspace=__ConvFit_Resolution,"
"WorkspaceIndex=0;((composite=ProductFunction,NumDeriv="
"false;name=Lorentzian,Amplitude=1,PeakCentre=0,FWHM=0."
"0175)))"
);
alg
.
setProperty
(
"BackgroundType"
,
"Fixed Flat"
);
alg
.
setProperty
(
"StartX"
,
0.0
);
alg
.
setProperty
(
"EndX"
,
5.0
);
alg
.
setProperty
(
"SpecMin"
,
0
);
alg
.
setProperty
(
"SpecMax"
,
0
);
alg
.
setProperty
(
"Convolve"
,
true
);
alg
.
setProperty
(
"Minimizer"
,
"Levenberg-Marquardt"
);
alg
.
setProperty
(
"MaxIterations"
,
500
);
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
());
TS_ASSERT
(
alg
.
isExecuted
());
// Assert that output is in ADS
TS_ASSERT_THROWS_NOTHING
(
AnalysisDataService
::
Instance
().
retrieveWS
<
ITableWorkspace
>
(
"SqwWs_conv_1LFixF_s0_to_5_Parameters"
));
TS_ASSERT_THROWS_NOTHING
(
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
"SqwWs_conv_1LFixF_s0_to_5_Result"
));
TS_ASSERT_THROWS_NOTHING
(
AnalysisDataService
::
Instance
().
retrieveWS
<
WorkspaceGroup
>
(
"SqwWs_conv_1LFixF_s0_to_5_Workspaces"
));
AnalysisDataService
::
Instance
().
clear
();
}
}
//------------------------ Private Functions---------------------------
//------------------------ Private Functions---------------------------
MatrixWorkspace_sptr
createGenericWorkspace
(
const
std
::
string
&
wsName
,
const
bool
numericAxis
)
{
const
auto
xData
=
boost
::
assign
::
list_of
(
1
)(
2
)(
3
)(
4
)(
5
)
.
convert_to_container
<
Mantid
::
MantidVec
>
();
const
auto
yData
=
boost
::
assign
::
list_of
(
0
)(
1
)(
3
)(
1
)(
0
)
.
convert_to_container
<
Mantid
::
MantidVec
>
();
auto
createWorkspace
=
AlgorithmManager
::
Instance
().
create
(
"CreateWorkspace"
);
createWorkspace
->
initialize
();
if
(
numericAxis
)
{
createWorkspace
->
setProperty
(
"UnitX"
,
"DeltaE"
);
createWorkspace
->
setProperty
(
"VerticalAxisUnit"
,
"MomentumTransfer"
);
createWorkspace
->
setProperty
(
"VerticalAxisValues"
,
"1"
);
}
else
{
createWorkspace
->
setProperty
(
"UnitX"
,
"DeltaE"
);
createWorkspace
->
setProperty
(
"VerticalAxisUnit"
,
"SpectraNumber"
);
}
createWorkspace
->
setProperty
(
"DataX"
,
xData
);
createWorkspace
->
setProperty
(
"DataY"
,
yData
);
createWorkspace
->
setProperty
(
"NSpec"
,
1
);
createWorkspace
->
setPropertyValue
(
"OutputWorkspace"
,
wsName
);
createWorkspace
->
execute
();
MatrixWorkspace_sptr
sqwWS
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
wsName
);
return
sqwWS
;
}
MatrixWorkspace_sptr
create2DWorkspace
(
int
xlen
,
int
ylen
)
{
MatrixWorkspace_sptr
create2DWorkspace
(
int
xlen
,
int
ylen
)
{
auto
ws
=
WorkspaceCreationHelper
::
create2DWorkspaceWithFullInstrument
(
auto
ws
=
WorkspaceCreationHelper
::
create2DWorkspaceWithFullInstrument
(
xlen
,
ylen
,
false
,
false
,
true
,
"testInst"
);
xlen
,
ylen
,
false
,
false
,
true
,
"testInst"
);
...
@@ -235,7 +308,7 @@ public:
...
@@ -235,7 +308,7 @@ public:
return
testWs
;
return
testWs
;
}
}
void
createConvitResWorkspace
(
int
totalHist
,
int
totalBins
)
{
void
createConv
F
itResWorkspace
(
int
totalHist
,
int
totalBins
)
{
auto
convFitRes
=
WorkspaceFactory
::
Instance
().
create
(
auto
convFitRes
=
WorkspaceFactory
::
Instance
().
create
(
"Workspace2D"
,
totalHist
+
1
,
totalBins
+
1
,
totalBins
);
"Workspace2D"
,
totalHist
+
1
,
totalBins
+
1
,
totalBins
);
boost
::
shared_ptr
<
Mantid
::
MantidVec
>
x1
(
boost
::
shared_ptr
<
Mantid
::
MantidVec
>
x1
(
...
...
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