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
79042441
Commit
79042441
authored
6 years ago
by
Samuel Jones
Browse files
Options
Downloads
Patches
Plain Diff
Re #22515 Fixing the template issue
parent
f4b6cc9a
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/Algorithms/src/SortXAxis2.cpp
+16
-24
16 additions, 24 deletions
Framework/Algorithms/src/SortXAxis2.cpp
with
16 additions
and
24 deletions
Framework/Algorithms/src/SortXAxis2.cpp
+
16
−
24
View file @
79042441
#include
"MantidAlgorithms/SortXAxis2.h"
#include
<iostream>
using
namespace
Mantid
::
Kernel
;
using
namespace
Mantid
::
API
;
...
...
@@ -211,14 +212,18 @@ void SortXAxis::copyToOutputWorkspace(
*/
template
<
typename
Comparator
>
bool
isItSorted
(
Comparator
const
&
compare
,
MatrixWorkspace_const_sptr
inputWorkspace
,
unsigned
int
specNum
)
{
return
std
::
is_sorted
(
inputWorkspace
->
x
(
specNum
).
begin
(),
MatrixWorkspace_const_sptr
inputWorkspace
)
{
for
(
auto
specNum
=
0u
;
specNum
<
inputWorkspace
->
getNumberHistograms
();
specNum
++
)
{
if
(
!
std
::
is_sorted
(
inputWorkspace
->
x
(
specNum
).
begin
(),
inputWorkspace
->
x
(
specNum
).
end
(),
[
&
](
std
::
size_t
lhs
,
std
::
size_t
rhs
)
->
bool
{
return
compare
(
inputWorkspace
->
x
(
specNum
)[
lhs
],
inputWorkspace
->
x
(
specNum
)[
rhs
]);
});
[
&
](
double
lhs
,
double
rhs
)
->
bool
{
return
compare
(
lhs
,
rhs
);
}))
{
return
false
;
}
}
return
true
;
}
/**
...
...
@@ -235,23 +240,10 @@ bool SortXAxis::determineIfHistogramIsValid(
if
(
inputWorkspace
->
x
(
0
).
size
()
!=
inputWorkspace
->
y
(
0
).
size
())
{
// The only way to guarantee that a histogram is a proper histogram, is to
// check whether each data value is in the correct order.
bool
ascending
=
true
;
for
(
auto
specNum
=
0u
;
specNum
<
inputWorkspace
->
getNumberHistograms
();
specNum
++
)
{
if
(
!
isItSorted
(
std
::
greater
<
double
>
(),
inputWorkspace
,
specNum
))
{
ascending
=
false
;
break
;
}
}
if
(
!
ascending
)
{
for
(
auto
specNum
=
0u
;
specNum
<
inputWorkspace
->
getNumberHistograms
();
specNum
++
)
{
if
(
!
isItSorted
(
std
::
less
<
double
>
(),
inputWorkspace
,
specNum
))
{
// It is not ascending nor descending and is thus not a histogram
throw
std
::
runtime_error
(
"Data entered looks like a histogram, but is "
"not a valid histogram"
);
}
if
(
!
isItSorted
(
std
::
greater
<
double
>
(),
inputWorkspace
))
{
if
(
!
isItSorted
(
std
::
less
<
double
>
(),
inputWorkspace
))
{
throw
std
::
runtime_error
(
"Data entered looks like a histogram, but is "
"not a valid histogram"
);
}
}
return
true
;
...
...
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