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
069604c7
Commit
069604c7
authored
Jul 18, 2013
by
Owen Arnold
Browse files
refs #7472. Adding tests for getGroup.
Lots of options for using getGroup. Cover the specific 'whattoget' arguments.
parent
b4b3b510
Changes
1
Hide whitespace changes
Inline
Side-by-side
Code/Mantid/scripts/test/ReflectometryQuickAuxiliaryTest.py
View file @
069604c7
import
unittest
import
numpy
from
MantidFramework
import
mtd
mtd
.
initialise
()
from
mantid.simpleapi
import
*
...
...
@@ -17,12 +18,15 @@ class ReflectometryQuickAuxiliaryTest(unittest.TestCase):
self
.
assertEqual
(
1
,
len
(
cleaned_object_names
))
self
.
assertEqual
(
True
,
(
'tokeep'
in
cleaned_object_names
))
DeleteWorkspace
(
tokeep
)
def
test_coAdd_ws_in_ADS
(
self
):
inWS
=
CreateSingleValuedWorkspace
(
DataValue
=
1
,
ErrorValue
=
1
)
quick
.
coAdd
(
'inWS'
,
'ProvidedName'
)
outWS
=
mtd
[
'_WProvidedName'
]
result
=
CheckWorkspacesMatch
(
Workspace1
=
inWS
,
Workspace2
=
outWS
)
self
.
assertEquals
(
"Success!"
,
result
)
DeleteWorkspace
(
outWS
)
def
test_coAdd_run_list
(
self
):
originalInstrument
=
config
.
getInstrument
()
...
...
@@ -49,7 +53,74 @@ class ReflectometryQuickAuxiliaryTest(unittest.TestCase):
self
.
assertEquals
(
"Success!"
,
result
)
finally
:
config
[
'default.instrument'
]
=
originalInstrument
.
name
()
DeleteWorkspace
(
a
[
0
])
DeleteWorkspace
(
b
[
0
])
DeleteWorkspace
(
c
)
DeleteWorkspace
(
outWS
)
def
test_groupGet_instrument
(
self
):
wsName
=
"TestWorkspace"
LoadISISNexus
(
Filename
=
'POLREF00004699'
,
OutputWorkspace
=
wsName
)
expectedInstrument
=
"POLREF"
# Test with group workspace as input
instrument
=
quick
.
groupGet
(
wsName
,
'inst'
)
self
.
assertEquals
(
expectedInstrument
,
instrument
.
getName
(),
"Did not fetch the instrument from ws group"
)
# Test with single workspace as input
instrument
=
quick
.
groupGet
(
mtd
[
wsName
][
0
].
name
(),
'inst'
)
self
.
assertEquals
(
expectedInstrument
,
instrument
.
getName
(),
"Did not fetch the instrument from ws"
)
DeleteWorkspace
(
mtd
[
wsName
])
def
test_groupGet_histogram_count
(
self
):
wsName
=
"TestWorkspace"
LoadISISNexus
(
Filename
=
'POLREF00004699'
,
OutputWorkspace
=
wsName
)
expectedNHistograms
=
mtd
[
wsName
][
0
].
getNumberHistograms
()
# Test with group workspace as input
nHistograms
=
quick
.
groupGet
(
wsName
,
'wksp'
)
self
.
assertEquals
(
expectedNHistograms
,
nHistograms
,
"Did not fetch the n histograms from ws group"
)
# Test with single workspace as input
nHistograms
=
quick
.
groupGet
(
mtd
[
wsName
][
0
].
name
(),
'wksp'
)
self
.
assertEquals
(
expectedNHistograms
,
nHistograms
,
"Did not fetch the n histograms from ws"
)
DeleteWorkspace
(
mtd
[
wsName
])
def
test_groupGet_log_single_value
(
self
):
wsName
=
"TestWorkspace"
LoadISISNexus
(
Filename
=
'POLREF00004699'
,
OutputWorkspace
=
wsName
)
expectedNPeriods
=
2
# Test with group workspace as input
nPeriods
=
quick
.
groupGet
(
wsName
,
'samp'
,
'nperiods'
)
self
.
assertEquals
(
expectedNPeriods
,
nPeriods
,
"Did not fetch the number of periods from ws group"
)
# Test with single workspace as input
nPeriods
=
quick
.
groupGet
(
mtd
[
wsName
][
0
].
name
(),
'samp'
,
'nperiods'
)
self
.
assertEquals
(
expectedNPeriods
,
nPeriods
,
"Did not fetch the number of periods from ws"
)
DeleteWorkspace
(
mtd
[
wsName
])
def
test_groupGet_multi_value_log
(
self
):
wsName
=
"TestWorkspace"
LoadISISNexus
(
Filename
=
'POLREF00004699'
,
OutputWorkspace
=
wsName
)
# Expected start theta, taken from the last value of the time series log.
expectedStartTheta
=
0.4903
# Test with group workspace as input
stheta
=
quick
.
groupGet
(
wsName
,
'samp'
,
'stheta'
)
self
.
assertEquals
(
expectedStartTheta
,
round
(
float
(
stheta
),
4
))
# Test with single workspace as input
stheta
=
quick
.
groupGet
(
mtd
[
wsName
][
0
].
name
(),
'samp'
,
'stheta'
)
self
.
assertEquals
(
expectedStartTheta
,
round
(
float
(
stheta
),
4
))
DeleteWorkspace
(
mtd
[
wsName
])
if
__name__
==
'__main__'
:
...
...
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