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
25c0a21e
Commit
25c0a21e
authored
5 years ago
by
Matthew Andrew
Browse files
Options
Downloads
Patches
Plain Diff
Updated IndirectFittingModelTest Re #28057
parent
e26f5926
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
qt/scientific_interfaces/Indirect/IndirectFittingModel.cpp
+4
-3
4 additions, 3 deletions
qt/scientific_interfaces/Indirect/IndirectFittingModel.cpp
qt/scientific_interfaces/Indirect/test/IndirectFittingModelTest.h
+36
-40
36 additions, 40 deletions
...tific_interfaces/Indirect/test/IndirectFittingModelTest.h
with
40 additions
and
43 deletions
qt/scientific_interfaces/Indirect/IndirectFittingModel.cpp
+
4
−
3
View file @
25c0a21e
...
...
@@ -776,8 +776,8 @@ IndirectFittingModel::mapDefaultParameterNames() const {
}
std
::
unordered_map
<
std
::
string
,
ParameterValue
>
IndirectFittingModel
::
createDefaultParameters
(
TableDatasetIndex
/*unused*/
)
const
{
IndirectFittingModel
::
createDefaultParameters
(
TableDatasetIndex
/*unused*/
)
const
{
return
std
::
unordered_map
<
std
::
string
,
ParameterValue
>
();
}
...
...
@@ -805,7 +805,8 @@ WorkspaceGroup_sptr IndirectFittingModel::getResultGroup() const {
bool
IndirectFittingModel
::
isPreviousModelSelected
()
const
{
return
m_fitFunction
&&
equivalentFunctions
(
getFittingFunction
(),
m_fitFunction
);
equivalentFunctions
(
extractFirstInnerFunction
(
getFittingFunction
()),
m_fitFunction
);
}
MultiDomainFunction_sptr
IndirectFittingModel
::
getMultiDomainFunction
()
const
{
...
...
This diff is collapsed.
Click to expand it.
qt/scientific_interfaces/Indirect/test/IndirectFittingModelTest.h
+
36
−
40
View file @
25c0a21e
...
...
@@ -7,10 +7,9 @@
#pragma once
#include
<cxxtest/TestSuite.h>
#include
<utility>
#include
"IndirectFittingModel
Legacy
.h"
#include
"IndirectFittingModel.h"
#include
"MantidAPI/FrameworkManager.h"
#include
"MantidAPI/FunctionFactory.h"
#include
"MantidAPI/MatrixWorkspace.h"
...
...
@@ -24,27 +23,29 @@ using namespace Mantid::CurveFitting;
using
namespace
Mantid
::
DataObjects
;
using
namespace
MantidQt
::
CustomInterfaces
::
IDA
;
using
namespace
Mantid
::
IndirectFitDataCreationHelper
;
using
namespace
MantidQt
::
CustomInterfaces
;
using
ConvolutionFitSequential
=
Algorithms
::
ConvolutionFit
<
Algorithms
::
QENSFitSequential
>
;
namespace
{
IFunction_sptr
getFunction
(
std
::
string
const
&
functionString
)
{
return
FunctionFactory
::
Instance
().
createInitialized
(
functionString
);
MultiDomainFunction_sptr
getFunction
(
std
::
string
const
&
functionString
)
{
return
FunctionFactory
::
Instance
().
createInitializedMultiDomainFunction
(
functionString
,
1
);
}
/// A dummy model used to inherit the methods which need testing
class
DummyModel
:
public
MantidQt
::
CustomInterfaces
::
IDA
::
IndirectFittingModel
Legacy
{
:
public
MantidQt
::
CustomInterfaces
::
IDA
::
IndirectFittingModel
{
public:
~
DummyModel
(){};
private
:
std
::
string
sequentialFitOutputName
()
const
override
{
return
""
;
};
std
::
string
simultaneousFitOutputName
()
const
override
{
return
""
;
};
std
::
string
singleFitOutputName
(
std
::
size_t
index
,
std
::
size_t
spectrum
)
const
override
{
std
::
string
singleFitOutputName
(
TableDatasetIndex
index
,
IDA
::
WorkspaceIndex
spectrum
)
const
override
{
UNUSED_ARG
(
index
);
UNUSED_ARG
(
spectrum
);
return
""
;
...
...
@@ -257,21 +258,21 @@ public:
test_that_getSpectra_returns_a_correct_spectra_when_the_index_provided_is_valid
()
{
auto
model
=
createModelWithSingleWorkspace
(
"WorkspaceName"
,
3
);
Spectra
Legacy
const
inputSpectra
=
DiscontinuousSpectra
<
std
::
size_t
>
(
"0-1"
);
Spectra
const
inputSpectra
=
Spectra
(
"0-1"
);
model
->
setSpectra
(
inputSpectra
,
0
);
Spectra
Legacy
const
spectra
=
model
->
getSpectra
(
0
);
Spectra
const
spectra
=
model
->
getSpectra
(
0
);
TS_ASSERT
(
boost
::
apply_visitor
(
AreSpectraEqual
(),
spectra
,
inputSpectra
)
)
;
TS_ASSERT
_EQUALS
(
spectra
,
inputSpectra
);
}
void
test_that_getSpectra_returns_an_empty_DiscontinuousSpectra_when_provided_an_out_of_range_index
()
{
auto
model
=
createModelWithSingleWorkspace
(
"WorkspaceName"
,
3
);
Spectra
Legacy
const
emptySpectra
(
DiscontinuousSpectra
<
std
::
size_t
>
(
""
));
Spectra
Legacy
const
spectra
=
model
->
getSpectra
(
3
);
Spectra
const
emptySpectra
(
Spectra
(
""
));
Spectra
const
spectra
=
model
->
getSpectra
(
3
);
TS_ASSERT
(
boost
::
apply_visitor
(
AreSpectraEqual
(),
spectra
,
emptySpectra
)
)
;
TS_ASSERT
_EQUALS
(
spectra
,
emptySpectra
);
}
void
...
...
@@ -302,7 +303,7 @@ public:
model
->
setStartX
(
1.2
,
0
,
0
);
model
->
setEndX
(
5.6
,
0
,
0
);
DiscontinuousSpectra
<
std
::
size_t
>
const
emptySpec
(
""
);
Spectra
const
emptySpec
(
""
);
model
->
setSpectra
(
emptySpec
,
0
);
TS_ASSERT_EQUALS
(
model
->
getFittingRange
(
0
,
0
).
first
,
0.0
);
...
...
@@ -332,7 +333,7 @@ public:
auto
model
=
createModelWithSingleWorkspace
(
"WorkspaceName"
,
1
);
model
->
setExcludeRegion
(
"0,1,3,4"
,
0
,
0
);
DiscontinuousSpectra
<
std
::
size_t
>
const
emptySpec
(
""
);
Spectra
const
emptySpec
(
""
);
model
->
setSpectra
(
emptySpec
,
0
);
TS_ASSERT_EQUALS
(
model
->
getExcludeRegion
(
1
,
0
),
""
);
...
...
@@ -457,29 +458,24 @@ public:
void
test_that_isPreviouslyFit_returns_true_if_the_spectrum_has_been_fitted_previously
()
{
auto
const
model
=
getModelWithFitOutputData
();
TS_ASSERT
(
model
->
isPreviouslyFit
(
0
,
0
));
TS_ASSERT
(
model
->
isPreviouslyFit
(
TableDatasetIndex
(
0
),
IDA
::
WorkspaceIndex
(
0
)));
}
void
test_that_
hasZeroSpectra_returns_true
_if_workspace_has_zero_spectra
()
{
void
test_that_
number_of_spectra_is_zero
_if_workspace_has_zero_spectra
()
{
auto
model
=
getEmptyModel
();
auto
const
workspace
=
std
::
make_shared
<
Workspace2D
>
();
SetUpADSWithWorkspace
ads
(
"WorkspaceEmpty"
,
workspace
);
model
->
addWorkspace
(
"WorkspaceEmpty"
);
TS_ASSERT
(
model
->
hasZeroSpectra
(
0
));
}
model
->
addWorkspace
(
"WorkspaceEmpty"
,
Spectra
(
""
));
void
test_that_hasZeroSpectra_returns_true_if_the_dataIndex_provided_is_out_of_range
()
{
auto
const
model
=
createModelWithSingleWorkspace
(
"WorkspaceName"
,
1
);
TS_ASSERT
(
model
->
hasZeroSpectra
(
1
));
TS_ASSERT
(
model
->
getSpectra
(
TableDatasetIndex
(
0
)).
size
()
==
0
);
}
void
test_that_
hasZeroSpectra_returns_false
_if_workspace_contains_one_or_more_spectra
()
{
test_that_
number_of_spectra_is_not_zero
_if_workspace_contains_one_or_more_spectra
()
{
auto
const
model
=
createModelWithSingleWorkspace
(
"WorkspaceName"
,
1
);
TS_ASSERT
(
!
model
->
hasZero
Spectra
(
0
)
);
TS_ASSERT
(
model
->
get
Spectra
(
TableDatasetIndex
(
0
)).
size
()
!=
0
);
}
void
...
...
@@ -558,23 +554,23 @@ public:
test_that_setSpectra_will_set_the_spectra_to_the_provided_inputSpectra
()
{
auto
model
=
createModelWithSingleWorkspace
(
"WorkspaceName"
,
10
);
SpectraLegacy
const
inputSpectra
=
DiscontinuousSpectra
<
std
::
size_t
>
(
"2,4,6-8"
);
Spectra
const
inputSpectra
=
Spectra
(
"2,4,6-8"
);
model
->
setSpectra
(
inputSpectra
,
0
);
Spectra
Legacy
const
spectra
=
model
->
getSpectra
(
0
);
Spectra
const
spectra
=
model
->
getSpectra
(
0
);
TS_ASSERT
(
boost
::
apply_visitor
(
AreSpectraEqual
(),
spectra
,
inputSpectra
)
)
;
TS_ASSERT
_EQUALS
(
spectra
,
inputSpectra
);
}
void
test_that_setSpectra_will_set_the_spectra_when_provided_a_spectra_pair
()
{
auto
model
=
createModelWithSingleWorkspace
(
"WorkspaceName"
,
10
);
SpectraLegacy
const
inputSpectra
=
std
::
make_pair
(
0u
,
5u
);
Spectra
const
inputSpectra
=
Spectra
(
IDA
::
WorkspaceIndex
(
0
),
IDA
::
WorkspaceIndex
(
5
));
model
->
setSpectra
(
inputSpectra
,
0
);
Spectra
Legacy
const
spectra
=
model
->
getSpectra
(
0
);
Spectra
const
spectra
=
model
->
getSpectra
(
0
);
TS_ASSERT
(
boost
::
apply_visitor
(
AreSpectraEqual
(),
spectra
,
inputSpectra
)
)
;
TS_ASSERT
_EQUALS
(
spectra
,
inputSpectra
);
}
void
...
...
@@ -587,7 +583,7 @@ public:
test_that_setStartX_will_set_the_startX_at_the_first_dataIndex_when_the_fit_is_sequential
()
{
auto
model
=
createModelWithSingleWorkspace
(
"WorkspaceName"
,
5
);
model
->
setStartX
(
4.0
,
3
,
0
);
model
->
setStartX
(
4.0
,
0
,
0
);
TS_ASSERT_EQUALS
(
model
->
getFittingRange
(
0
,
0
).
first
,
4.0
);
}
...
...
@@ -596,7 +592,7 @@ public:
test_that_setEndX_will_set_the_endX_at_the_first_dataIndex_when_the_fit_is_sequential
()
{
auto
model
=
createModelWithSingleWorkspace
(
"WorkspaceName"
,
5
);
model
->
setEndX
(
4.0
,
3
,
0
);
model
->
setEndX
(
4.0
,
0
,
0
);
TS_ASSERT_EQUALS
(
model
->
getFittingRange
(
0
,
0
).
second
,
4.0
);
}
...
...
@@ -605,7 +601,7 @@ public:
test_that_setExcludeRegion_set_the_excludeRegion_at_the_first_dataIndex_when_the_fit_is_sequential
()
{
auto
model
=
createModelWithSingleWorkspace
(
"WorkspaceName"
,
5
);
model
->
setExcludeRegion
(
"0,1,3,4"
,
3
,
0
);
model
->
setExcludeRegion
(
"0,1,3,4"
,
0
,
0
);
TS_ASSERT_EQUALS
(
model
->
getExcludeRegion
(
0
,
0
),
"0.000,1.000,3.000,4.000"
);
}
...
...
@@ -646,7 +642,7 @@ public:
model
->
setDefaultParameterValue
(
"Amplitude"
,
1.5
,
0
);
auto
const
parameters
=
model
->
getDefaultParameters
(
0
);
TS_ASSERT_EQUALS
(
parameters
.
at
(
"f1.f1.f0.Amplitude"
).
value
,
1.5
);
TS_ASSERT_EQUALS
(
parameters
.
at
(
"
f0.
f1.f1.f0.Amplitude"
).
value
,
1.5
);
}
void
...
...
@@ -664,7 +660,7 @@ public:
model
->
setDefaultParameterValue
(
"Amplitude"
,
1.5
,
0
);
auto
const
parameters
=
model
->
getParameterValues
(
0
,
0
);
TS_ASSERT_EQUALS
(
parameters
.
at
(
"f1.f1.f0.Amplitude"
).
value
,
1.5
);
TS_ASSERT_EQUALS
(
parameters
.
at
(
"
f0.
f1.f1.f0.Amplitude"
).
value
,
1.5
);
}
void
...
...
@@ -709,7 +705,7 @@ public:
auto
const
parameters
=
model
->
getDefaultParameters
(
0
);
TS_ASSERT
(
!
parameters
.
empty
());
TS_ASSERT_DELTA
(
parameters
.
at
(
"f1.f1.f0.Amplitude"
).
value
,
1.5
,
0.0001
);
TS_ASSERT_DELTA
(
parameters
.
at
(
"
f0.
f1.f1.f0.Amplitude"
).
value
,
1.5
,
0.0001
);
}
void
test_that_getResultLocation_returns_a_location_for_the_output_data
()
{
...
...
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