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
6228c1f3
Commit
6228c1f3
authored
10 years ago
by
Harry Jeffery
Browse files
Options
Downloads
Patches
Plain Diff
Refs #11355 Transfer orthogonal slice with scaling test
parent
c55a64d9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/Mantid/Framework/MDAlgorithms/test/CutMDTest.h
+64
-0
64 additions, 0 deletions
Code/Mantid/Framework/MDAlgorithms/test/CutMDTest.h
Code/Mantid/Framework/PythonInterface/test/python/mantid/api/CutMDTest.py
+0
-43
0 additions, 43 deletions
...ework/PythonInterface/test/python/mantid/api/CutMDTest.py
with
64 additions
and
43 deletions
Code/Mantid/Framework/MDAlgorithms/test/CutMDTest.h
+
64
−
0
View file @
6228c1f3
...
...
@@ -6,6 +6,8 @@
#include
"MantidAPI/FrameworkManager.h"
#include
"MantidAPI/IMDWorkspace.h"
#include
"MantidAPI/IMDEventWorkspace.h"
#include
"MantidAPI/IMDHistoWorkspace.h"
#include
"MantidAPI/TableRow.h"
#include
<cxxtest/TestSuite.h>
...
...
@@ -232,6 +234,68 @@ public:
algCutMD
->
setProperty
(
"CheckAxes"
,
false
);
TS_ASSERT_THROWS
(
algCutMD
->
execute
(),
std
::
runtime_error
);
}
void
test_orthogonal_slice_with_scaling
()
{
const
std
::
string
wsName
=
"__CutMDTest_orthog_slice_with_scaling"
;
FrameworkManager
::
Instance
().
exec
(
"CreateMDWorkspace"
,
10
,
"OutputWorkspace"
,
wsName
.
c_str
(),
"Dimensions"
,
"3"
,
"Extents"
,
"-1,1,-1,1,-1,1"
,
"Names"
,
"H,K,L"
,
"Units"
,
"U,U,U"
);
FrameworkManager
::
Instance
().
exec
(
"SetUB"
,
14
,
"Workspace"
,
wsName
.
c_str
(),
"a"
,
"1"
,
"b"
,
"1"
,
"c"
,
"1"
,
"alpha"
,
"90"
,
"beta"
,
"90"
,
"gamma"
,
"90"
);
FrameworkManager
::
Instance
().
exec
(
"SetSpecialCoordinates"
,
4
,
"InputWorkspace"
,
wsName
.
c_str
(),
"SpecialCoordinates"
,
"HKL"
);
ITableWorkspace_sptr
proj
=
WorkspaceFactory
::
Instance
().
createTable
();
proj
->
addColumn
(
"str"
,
"name"
);
proj
->
addColumn
(
"str"
,
"value"
);
proj
->
addColumn
(
"double"
,
"offset"
);
proj
->
addColumn
(
"str"
,
"type"
);
TableRow
uRow
=
proj
->
appendRow
();
TableRow
vRow
=
proj
->
appendRow
();
TableRow
wRow
=
proj
->
appendRow
();
uRow
<<
"u"
<<
"1,0,0"
<<
0.0
<<
"r"
;
vRow
<<
"v"
<<
"0,1,0"
<<
0.0
<<
"r"
;
wRow
<<
"w"
<<
"0,0,1"
<<
0.0
<<
"r"
;
auto
algCutMD
=
FrameworkManager
::
Instance
().
createAlgorithm
(
"CutMD"
);
algCutMD
->
initialize
();
algCutMD
->
setRethrows
(
true
);
algCutMD
->
setProperty
(
"InputWorkspace"
,
wsName
);
algCutMD
->
setProperty
(
"OutputWorkspace"
,
wsName
);
algCutMD
->
setProperty
(
"Projection"
,
proj
);
algCutMD
->
setProperty
(
"P1Bin"
,
"-0.5,0.5"
);
algCutMD
->
setProperty
(
"P2Bin"
,
"-0.1,0.1"
);
algCutMD
->
setProperty
(
"P3Bin"
,
"-0.3,0.3"
);
algCutMD
->
setProperty
(
"NoPix"
,
true
);
algCutMD
->
execute
();
TS_ASSERT
(
algCutMD
->
isExecuted
());
IMDHistoWorkspace_sptr
outWS
=
AnalysisDataService
::
Instance
().
retrieveWS
<
IMDHistoWorkspace
>
(
wsName
);
TS_ASSERT
(
outWS
.
get
());
TS_ASSERT_DELTA
(
outWS
->
getDimension
(
0
)
->
getMinimum
(),
-
0.5
,
1E-6
);
TS_ASSERT_DELTA
(
outWS
->
getDimension
(
0
)
->
getMaximum
(),
0.5
,
1E-6
);
TS_ASSERT_DELTA
(
outWS
->
getDimension
(
1
)
->
getMinimum
(),
-
0.1
,
1E-6
);
TS_ASSERT_DELTA
(
outWS
->
getDimension
(
1
)
->
getMaximum
(),
0.1
,
1E-6
);
TS_ASSERT_DELTA
(
outWS
->
getDimension
(
2
)
->
getMinimum
(),
-
0.3
,
1E-6
);
TS_ASSERT_DELTA
(
outWS
->
getDimension
(
2
)
->
getMaximum
(),
0.3
,
1E-6
);
TS_ASSERT_EQUALS
(
"['zeta', 0, 0]"
,
outWS
->
getDimension
(
0
)
->
getName
());
TS_ASSERT_EQUALS
(
"[0, 'eta', 0]"
,
outWS
->
getDimension
(
1
)
->
getName
());
TS_ASSERT_EQUALS
(
"[0, 0, 'xi']"
,
outWS
->
getDimension
(
2
)
->
getName
());
AnalysisDataService
::
Instance
().
remove
(
wsName
);
}
};
#endif
/* MANTID_MDALGORITHMS_CUTMDTEST_H_ */
This diff is collapsed.
Click to expand it.
Code/Mantid/Framework/PythonInterface/test/python/mantid/api/CutMDTest.py
+
0
−
43
View file @
6228c1f3
...
...
@@ -22,49 +22,6 @@ class CutMDTest(unittest.TestCase):
def
tearDown
(
self
):
DeleteWorkspace
(
self
.
__in_md
)
def
test_orthogonal_slice_with_scaling
(
self
):
# We create a fake workspace and check to see that the extents get scaled with the new coordinate system when sliced
to_cut
=
CreateMDWorkspace
(
Dimensions
=
3
,
Extents
=
[
-
1
,
1
,
-
1
,
1
,
-
1
,
1
],
Names
=
'
H,K,L
'
,
Units
=
'
U,U,U
'
)
# Set the UB
SetUB
(
Workspace
=
to_cut
,
a
=
1
,
b
=
1
,
c
=
1
,
alpha
=
90
,
beta
=
90
,
gamma
=
90
)
SetSpecialCoordinates
(
InputWorkspace
=
to_cut
,
SpecialCoordinates
=
'
HKL
'
)
scale_x
=
2.0
scale_y
=
2.0
projection
=
CreateEmptyTableWorkspace
()
# Correct number of columns, and names
projection
.
addColumn
(
"
str
"
,
"
name
"
)
projection
.
addColumn
(
"
str
"
,
"
value
"
)
projection
.
addColumn
(
"
double
"
,
"
offset
"
)
projection
.
addColumn
(
"
str
"
,
"
type
"
)
projection
.
addRow
([
"
u
"
,
"
%s,0,0
"
%
scale_x
,
0
,
"
r
"
])
projection
.
addRow
([
"
v
"
,
"
0,%s,0
"
%
scale_y
,
0
,
"
r
"
])
u
=
map
(
float
,
projection
.
cell
(
0
,
1
).
split
(
"
,
"
))
v
=
map
(
float
,
projection
.
cell
(
1
,
1
).
split
(
"
,
"
))
scale_z
=
np
.
cross
(
v
,
u
)[
-
1
]
projection
.
addRow
([
"
w
"
,
"
0,0,%s
"
%
scale_z
,
0
,
"
r
"
])
out_md
=
CutMD
(
to_cut
,
Projection
=
projection
,
P1Bin
=
[
0.1
],
P2Bin
=
[
0.1
],
P3Bin
=
[
0.1
])
'''
Here we check that the corners in HKL end up in the expected positions when transformed into the new scaled basis
provided by the W transform (projection table)
'''
self
.
assertEquals
(
-
(
1
/
scale_x
),
out_md
.
getDimension
(
0
).
getMinimum
())
self
.
assertEquals
((
1
/
scale_x
),
out_md
.
getDimension
(
0
).
getMaximum
())
self
.
assertEquals
(
-
(
1
/
scale_y
),
out_md
.
getDimension
(
1
).
getMinimum
())
self
.
assertEquals
((
1
/
scale_y
),
out_md
.
getDimension
(
1
).
getMaximum
())
self
.
assertEquals
((
1
/
scale_z
),
out_md
.
getDimension
(
2
).
getMinimum
())
self
.
assertEquals
(
-
(
1
/
scale_z
),
out_md
.
getDimension
(
2
).
getMaximum
())
self
.
assertEquals
(
"
[
'
2.00zeta
'
, 0, 0]
"
,
out_md
.
getDimension
(
0
).
getName
()
)
self
.
assertEquals
(
"
[0,
'
2.00eta
'
, 0]
"
,
out_md
.
getDimension
(
1
).
getName
()
)
self
.
assertEquals
(
"
[0, 0,
'
-4.00xi
'
]
"
,
out_md
.
getDimension
(
2
).
getName
()
)
def
test_non_orthogonal_slice
(
self
):
# We create a fake workspace and check to see that the extents get transformed to the new coordinate system.
to_cut
=
CreateMDWorkspace
(
Dimensions
=
3
,
Extents
=
[
-
1
,
1
,
-
1
,
1
,
-
1
,
1
],
Names
=
'
H,K,L
'
,
Units
=
'
U,U,U
'
)
...
...
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