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
85ebc8f5
Commit
85ebc8f5
authored
9 years ago
by
Anton Piccardo-Selg
Browse files
Options
Downloads
Patches
Plain Diff
Refs #13872 Add further unit detection to HKL
parent
10cbb0bf
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/API/test/MDGeometryTest.h
+18
-10
18 additions, 10 deletions
Framework/API/test/MDGeometryTest.h
Framework/Kernel/src/MDUnitFactory.cpp
+7
-1
7 additions, 1 deletion
Framework/Kernel/src/MDUnitFactory.cpp
with
25 additions
and
11 deletions
Framework/API/test/MDGeometryTest.h
+
18
−
10
View file @
85ebc8f5
...
...
@@ -12,12 +12,14 @@
#include
"MantidAPI/IMDWorkspace.h"
#include
"MantidTestHelpers/FakeObjects.h"
#include
"MantidAPI/NullCoordTransform.h"
#include
"MantidGeometry/MDGeometry/QSample.h"
using
namespace
Mantid
;
using
namespace
Mantid
::
Kernel
;
using
namespace
Mantid
::
API
;
using
namespace
Mantid
::
Geometry
;
class
MDGeometryTest
:
public
CxxTest
::
TestSuite
{
public:
// This pair of boilerplate methods prevent the suite being created statically
...
...
@@ -28,8 +30,9 @@ public:
void
test_initGeometry
()
{
MDGeometry
g
;
std
::
vector
<
IMDDimension_sptr
>
dims
;
IMDDimension_sptr
dim1
(
new
MDHistoDimension
(
"Qx"
,
"Qx"
,
"Ang"
,
-
1
,
+
1
,
10
));
IMDDimension_sptr
dim2
(
new
MDHistoDimension
(
"Qy"
,
"Qy"
,
"Ang"
,
-
1
,
+
1
,
20
));
const
Mantid
::
Geometry
::
QSample
frame
;
IMDDimension_sptr
dim1
(
new
MDHistoDimension
(
"Qx"
,
"Qx"
,
frame
,
-
1
,
+
1
,
10
));
IMDDimension_sptr
dim2
(
new
MDHistoDimension
(
"Qy"
,
"Qy"
,
frame
,
-
1
,
+
1
,
20
));
dims
.
push_back
(
dim1
);
dims
.
push_back
(
dim2
);
g
.
initGeometry
(
dims
);
...
...
@@ -86,8 +89,9 @@ public:
void
test_copy_constructor
()
{
MDGeometry
g
;
std
::
vector
<
IMDDimension_sptr
>
dims
;
IMDDimension_sptr
dim0
(
new
MDHistoDimension
(
"Qx"
,
"Qx"
,
"Ang"
,
-
1
,
+
1
,
0
));
IMDDimension_sptr
dim1
(
new
MDHistoDimension
(
"Qy"
,
"Qy"
,
"Ang"
,
-
1
,
+
1
,
0
));
const
Mantid
::
Geometry
::
QSample
frame
;
IMDDimension_sptr
dim0
(
new
MDHistoDimension
(
"Qx"
,
"Qx"
,
frame
,
-
1
,
+
1
,
0
));
IMDDimension_sptr
dim1
(
new
MDHistoDimension
(
"Qy"
,
"Qy"
,
frame
,
-
1
,
+
1
,
0
));
dims
.
push_back
(
dim0
);
dims
.
push_back
(
dim1
);
g
.
initGeometry
(
dims
);
...
...
@@ -136,11 +140,12 @@ public:
/** Adding dimension info and searching for it back */
void
test_addDimension_getDimension
()
{
MDGeometry
g
;
const
Mantid
::
Geometry
::
QSample
frame
;
MDHistoDimension_sptr
dim
(
new
MDHistoDimension
(
"Qx"
,
"Qx"
,
"Ang"
,
-
1
,
+
1
,
0
));
new
MDHistoDimension
(
"Qx"
,
"Qx"
,
frame
,
-
1
,
+
1
,
0
));
TS_ASSERT_THROWS_NOTHING
(
g
.
addDimension
(
dim
);)
MDHistoDimension_sptr
dim2
(
new
MDHistoDimension
(
"Qy"
,
"Qy"
,
"Ang"
,
-
1
,
+
1
,
0
));
new
MDHistoDimension
(
"Qy"
,
"Qy"
,
frame
,
-
1
,
+
1
,
0
));
TS_ASSERT_THROWS_NOTHING
(
g
.
addDimension
(
dim2
);)
TS_ASSERT_EQUALS
(
g
.
getNumDims
(),
2
);
TS_ASSERT_EQUALS
(
g
.
getDimension
(
0
)
->
getName
(),
"Qx"
);
...
...
@@ -152,11 +157,12 @@ public:
void
test_transformDimensions
()
{
MDGeometry
g
;
const
Mantid
::
Geometry
::
QSample
frame
;
MDHistoDimension_sptr
dim
(
new
MDHistoDimension
(
"Qx"
,
"Qx"
,
"Ang"
,
-
1
,
+
1
,
0
));
new
MDHistoDimension
(
"Qx"
,
"Qx"
,
frame
,
-
1
,
+
1
,
0
));
TS_ASSERT_THROWS_NOTHING
(
g
.
addDimension
(
dim
);)
MDHistoDimension_sptr
dim2
(
new
MDHistoDimension
(
"Qy"
,
"Qy"
,
"Ang"
,
-
2
,
+
2
,
0
));
new
MDHistoDimension
(
"Qy"
,
"Qy"
,
frame
,
-
2
,
+
2
,
0
));
TS_ASSERT_THROWS_NOTHING
(
g
.
addDimension
(
dim2
);)
TS_ASSERT_EQUALS
(
g
.
getNumDims
(),
2
);
boost
::
shared_ptr
<
WorkspaceTester
>
ws
(
new
WorkspaceTester
());
...
...
@@ -262,8 +268,9 @@ public:
void
test_all_normalized
()
{
MDGeometry
geometry
;
std
::
vector
<
IMDDimension_sptr
>
dims
;
IMDDimension_sptr
dim1
(
new
MDHistoDimension
(
"Qx"
,
"Qx"
,
"Ang"
,
-
1
,
+
1
,
10
));
IMDDimension_sptr
dim2
(
new
MDHistoDimension
(
"Qy"
,
"Qy"
,
"Ang"
,
-
1
,
+
1
,
20
));
const
Mantid
::
Geometry
::
QSample
frame
;
IMDDimension_sptr
dim1
(
new
MDHistoDimension
(
"Qx"
,
"Qx"
,
frame
,
-
1
,
+
1
,
10
));
IMDDimension_sptr
dim2
(
new
MDHistoDimension
(
"Qy"
,
"Qy"
,
frame
,
-
1
,
+
1
,
20
));
dims
.
push_back
(
dim1
);
dims
.
push_back
(
dim2
);
geometry
.
initGeometry
(
dims
);
...
...
@@ -285,6 +292,7 @@ public:
TSM_ASSERT
(
"All basis vectors are normalized"
,
geometry
.
allBasisNormalized
());
}
};
#endif
/* MANTID_API_MDGEOMETRYTEST_H_ */
This diff is collapsed.
Click to expand it.
Framework/Kernel/src/MDUnitFactory.cpp
+
7
−
1
View file @
85ebc8f5
...
...
@@ -35,7 +35,13 @@ ReciprocalLatticeUnitFactory::createRaw(const std::string &) const {
bool
ReciprocalLatticeUnitFactory
::
canInterpret
(
const
std
::
string
&
unitString
)
const
{
return
unitString
==
Units
::
Symbol
::
RLU
.
ascii
();
auto
isRLU
=
unitString
==
Units
::
Symbol
::
RLU
.
ascii
();
// In addition to having RLU we can encounter units of type "in 6.28 A^-1"
// We need to account for the latter here
boost
::
regex
pattern
(
"in.*A
\\
^-1"
);
auto
isHoraceStyle
=
boost
::
regex_match
(
unitString
,
pattern
);
return
isRLU
||
isHoraceStyle
;
}
MDUnitFactory_uptr
makeMDUnitFactoryChain
()
{
...
...
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