Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
455e2a6c
Commit
455e2a6c
authored
Feb 23, 2018
by
Lynch, Vickie
Browse files
Refs #21752 unit tests changed because formula for Zscore changed
parent
fae29557
Changes
6
Hide whitespace changes
Inline
Side-by-side
Framework/Crystal/src/PeakStatisticsTools.cpp
View file @
455e2a6c
...
...
@@ -210,6 +210,8 @@ UniqueReflectionCollection::getReflections() const {
* group of equivalent reflections.
*
* @param uniqueReflections :: Map of unique reflections and peaks.
* @param equivalentIntensities :: Mean or median for statistics of equivalent peaks.
* @param sigmaCritical :: Number of standard deviations for outliers.
*/
void
PeaksStatistics
::
calculatePeaksStatistics
(
const
std
::
map
<
V3D
,
UniqueReflection
>
&
uniqueReflections
,
...
...
Framework/Crystal/src/SortHKL.cpp
View file @
455e2a6c
...
...
@@ -128,11 +128,11 @@ void SortHKL::exec() {
auto
wavelengths
=
unique
.
second
.
getWavelengths
();
auto
intensities
=
unique
.
second
.
getIntensities
();
auto
sigmas
=
unique
.
second
.
getSigmas
();
std
::
cout
<<
"HKL "
<<
unique
.
second
.
getHKL
()
<<
"
\n
"
;
std
::
cout
<<
"Intensities "
;
for
(
const
auto
&
e
:
intensities
)
std
::
cout
<<
e
<<
" "
;
std
::
cout
<<
"
\n
"
;
//
std::cout << "HKL " << unique.second.getHKL() << "\n";
//
std::cout << "Intensities ";
//
for (const auto &e : intensities)
//
std::cout << e << " ";
//
std::cout << "\n";
auto
zScores
=
Kernel
::
getWeightedZscore
(
intensities
,
sigmas
);
if
(
zScores
.
size
()
>
maxPeaks
)
maxPeaks
=
zScores
.
size
();
...
...
@@ -143,8 +143,8 @@ void SortHKL::exec() {
Kernel
::
getStatistics
(
outliersRemoved
.
getIntensities
(),
StatOptions
::
Mean
|
StatOptions
::
Median
);
std
::
cout
<<
"Mean = "
<<
intensityStatistics
.
mean
<<
" Median = "
<<
intensityStatistics
.
median
<<
"
\n
"
;
//
std::cout << "Mean = " << intensityStatistics.mean
//
<< " Median = " << intensityStatistics.median << "\n";
// sort wavelengths & intensities
for
(
size_t
i
=
0
;
i
<
wavelengths
.
size
();
i
++
)
{
size_t
i0
=
i
;
...
...
@@ -161,7 +161,7 @@ void SortHKL::exec() {
intensities
[
i0
]
=
intensities
[
i
];
intensities
[
i
]
=
temp
;
}
std
::
cout
<<
"Zscores "
;
//
std::cout << "Zscores ";
for
(
size_t
i
=
0
;
i
<
std
::
min
(
zScores
.
size
(),
static_cast
<
size_t
>
(
20
));
++
i
)
{
UniqX
[
i
]
=
wavelengths
[
i
];
...
...
@@ -172,14 +172,14 @@ void SortHKL::exec() {
UniqE
[
i
]
=
intensityStatistics
.
mean
-
intensities
[
i
];
else
UniqE
[
i
]
=
intensityStatistics
.
median
-
intensities
[
i
];
std
::
cout
<<
zScores
[
i
]
<<
" "
;
//
std::cout << zScores[i] << " ";
}
for
(
size_t
i
=
zScores
.
size
();
i
<
20
;
++
i
)
{
UniqX
[
i
]
=
wavelengths
[
zScores
.
size
()
-
1
];
UniqY
[
i
]
=
intensities
[
zScores
.
size
()
-
1
];
UniqE
[
i
]
=
0.0
;
}
std
::
cout
<<
"
\n
"
;
//
std::cout << "\n";
}
}
...
...
Framework/Crystal/test/PeakStatisticsToolsTest.h
View file @
455e2a6c
...
...
@@ -161,21 +161,20 @@ public:
auto
cleanReflection
=
reflection
.
removeOutliers
();
TSM_ASSERT_EQUALS
(
"UniqueReflection removed outlier although it should not."
,
cleanReflection
.
count
(),
4
);
cleanReflection
.
count
(),
3
);
cleanReflection
=
reflection
.
removeOutliers
(
2.0
);
TSM_ASSERT_EQUALS
(
"UniqueReflection removed outlier although it should not."
,
cleanReflection
.
count
(),
4
);
cleanReflection
.
count
(),
2
);
cleanReflection
=
reflection
.
removeOutliers
(
1.0
);
TSM_ASSERT_EQUALS
(
"UniqueReflection did not remove outliers although it should have."
,
cleanReflection
.
count
(),
2
);
cleanReflection
.
count
(),
1
);
std
::
vector
<
double
>
cleanIntensities
=
cleanReflection
.
getIntensities
();
TS_ASSERT_EQUALS
(
cleanIntensities
[
0
],
32.0
);
TS_ASSERT_EQUALS
(
cleanIntensities
[
1
],
31.0
);
}
void
test_UniqueReflectionSetIntensityAndSigma
()
{
...
...
@@ -263,7 +262,9 @@ public:
std
::
make_pair
(
V3D
(
1
,
1
,
1
),
UniqueReflection
(
V3D
(
1
,
1
,
1
))));
MockUniqueReflectionCollection
reflections
(
uniques
);
PeaksStatistics
statistics
(
reflections
);
std
::
string
statType
=
"Mean"
;
double
sigmas
=
3.0
;
PeaksStatistics
statistics
(
reflections
,
statType
,
sigmas
);
TS_ASSERT_EQUALS
(
statistics
.
m_peaks
.
size
(),
0
);
TS_ASSERT_EQUALS
(
statistics
.
m_uniqueReflections
,
0
);
TS_ASSERT_EQUALS
(
statistics
.
m_redundancy
,
0.0
);
...
...
@@ -278,7 +279,9 @@ public:
{{
1
,
1
,
1
},
getReflectionWithPeaks
({
56.0
},
{
4.5
},
1.0
)}};
MockUniqueReflectionCollection
reflections
(
uniques
);
PeaksStatistics
statistics
(
reflections
);
std
::
string
statType
=
"Mean"
;
double
sigmas
=
3.0
;
PeaksStatistics
statistics
(
reflections
,
statType
,
sigmas
);
TS_ASSERT_EQUALS
(
statistics
.
m_peaks
.
size
(),
1
);
TS_ASSERT_EQUALS
(
statistics
.
m_uniqueReflections
,
1
);
TS_ASSERT_EQUALS
(
statistics
.
m_redundancy
,
1.0
);
...
...
@@ -294,7 +297,9 @@ public:
{{
1
,
1
,
2
},
UniqueReflection
(
V3D
(
1
,
1
,
2
))}};
MockUniqueReflectionCollection
reflections
(
uniques
);
PeaksStatistics
statistics
(
reflections
);
std
::
string
statType
=
"Mean"
;
double
sigmas
=
3.0
;
PeaksStatistics
statistics
(
reflections
,
statType
,
sigmas
);
TS_ASSERT_EQUALS
(
statistics
.
m_peaks
.
size
(),
1
);
TS_ASSERT_EQUALS
(
statistics
.
m_uniqueReflections
,
1
);
TS_ASSERT_EQUALS
(
statistics
.
m_redundancy
,
1.0
);
...
...
@@ -311,7 +316,9 @@ public:
{{
1
,
1
,
2
},
getReflectionWithPeaks
({
20.0
},
{
1.0
},
2.0
)}};
MockUniqueReflectionCollection
reflections
(
uniques
);
PeaksStatistics
statistics
(
reflections
);
std
::
string
statType
=
"Mean"
;
double
sigmas
=
3.0
;
PeaksStatistics
statistics
(
reflections
,
statType
,
sigmas
);
TS_ASSERT_EQUALS
(
statistics
.
m_peaks
.
size
(),
2
);
TS_ASSERT_EQUALS
(
statistics
.
m_uniqueReflections
,
2
);
TS_ASSERT_EQUALS
(
statistics
.
m_redundancy
,
1.0
);
...
...
@@ -326,7 +333,9 @@ public:
{{
1
,
1
,
1
},
getReflectionWithPeaks
({
10.0
,
20.0
},
{
0.1
,
0.1
},
1.0
)}};
MockUniqueReflectionCollection
reflections
(
uniques
);
PeaksStatistics
statistics
(
reflections
);
std
::
string
statType
=
"Mean"
;
double
sigmas
=
3.0
;
PeaksStatistics
statistics
(
reflections
,
statType
,
sigmas
);
TS_ASSERT_EQUALS
(
statistics
.
m_peaks
.
size
(),
2
);
TS_ASSERT_EQUALS
(
statistics
.
m_uniqueReflections
,
1
);
TS_ASSERT_EQUALS
(
statistics
.
m_redundancy
,
2.0
);
...
...
@@ -344,7 +353,9 @@ public:
getReflectionWithPeaks
({
10.0
,
20.0
,
15.0
},
{
0.1
,
0.1
,
0.1
},
1.0
)}};
MockUniqueReflectionCollection
reflections
(
uniques
);
PeaksStatistics
statistics
(
reflections
);
std
::
string
statType
=
"Mean"
;
double
sigmas
=
3.0
;
PeaksStatistics
statistics
(
reflections
,
statType
,
sigmas
);
TS_ASSERT_EQUALS
(
statistics
.
m_peaks
.
size
(),
3
);
TS_ASSERT_EQUALS
(
statistics
.
m_uniqueReflections
,
1
);
TS_ASSERT_EQUALS
(
statistics
.
m_redundancy
,
3.0
);
...
...
Framework/Crystal/test/StatisticsOfPeaksWorkspaceTest.h
View file @
455e2a6c
...
...
@@ -81,9 +81,9 @@ public:
TS_ASSERT_EQUALS
(
tableOut
->
String
(
0
,
0
),
"Overall"
);
TS_ASSERT_EQUALS
(
tableOut
->
Int
(
0
,
1
),
3
);
TS_ASSERT_DELTA
(
tableOut
->
Double
(
0
,
2
),
3.6
,
.1
);
TS_ASSERT_DELTA
(
tableOut
->
Double
(
0
,
3
),
14.3
,
.1
);
TS_ASSERT_DELTA
(
tableOut
->
Double
(
0
,
4
),
8.
,
.1
);
TS_ASSERT_DELTA
(
tableOut
->
Double
(
0
,
5
),
1.
419
5
,
.1
);
TS_ASSERT_DELTA
(
tableOut
->
Double
(
0
,
3
),
14.
0
3
,
.1
);
TS_ASSERT_DELTA
(
tableOut
->
Double
(
0
,
4
),
5.3
,
.1
);
TS_ASSERT_DELTA
(
tableOut
->
Double
(
0
,
5
),
1.
2
5
,
.1
);
TS_ASSERT_DELTA
(
tableOut
->
Double
(
0
,
6
),
0.
,
.1
);
TS_ASSERT_DELTA
(
tableOut
->
Double
(
0
,
7
),
0.
,
.1
);
...
...
@@ -94,7 +94,7 @@ public:
TS_ASSERT
(
wsout
);
if
(
!
wsout
)
return
;
TS_ASSERT_EQUALS
(
wsout
->
getNumberPeaks
(),
24
);
TS_ASSERT_EQUALS
(
wsout
->
getNumberPeaks
(),
16
);
Peak
p
=
wsout
->
getPeaks
()[
0
];
TS_ASSERT_EQUALS
(
p
.
getH
(),
1
);
...
...
Framework/DataObjects/src/Peak.cpp
View file @
455e2a6c
...
...
@@ -890,7 +890,7 @@ void Peak::setCol(int m_col) { this->m_col = m_col; }
// -------------------------------------------------------------------------------------
/** Sets the unique peak number
* @param m_
col :: col
value */
* @param m_
peakNumber :: unique peak number
value */
void
Peak
::
setPeakNumber
(
int
m_peakNumber
)
{
this
->
m_peakNumber
=
m_peakNumber
;
}
...
...
Framework/Geometry/test/MockObjects.h
View file @
455e2a6c
...
...
@@ -65,7 +65,9 @@ public:
MOCK_CONST_METHOD0
(
getDetector
,
Geometry
::
IDetector_const_sptr
());
MOCK_CONST_METHOD0
(
getInstrument
,
Geometry
::
Instrument_const_sptr
());
MOCK_CONST_METHOD0
(
getRunNumber
,
int
());
MOCK_CONST_METHOD0
(
getPeakNumber
,
int
());
MOCK_METHOD1
(
setRunNumber
,
void
(
int
m_RunNumber
));
MOCK_METHOD1
(
setPeakNumber
,
void
(
int
m_PeakNumber
));
MOCK_CONST_METHOD0
(
getMonitorCount
,
double
());
MOCK_METHOD1
(
setMonitorCount
,
void
(
double
m_MonitorCount
));
MOCK_CONST_METHOD0
(
getH
,
double
());
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment