Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
d627d12d
Commit
d627d12d
authored
Aug 02, 2021
by
Gemma Guest
Browse files
Add test for validating workspace groups
Re #32125
parent
d19fbb23
Changes
2
Hide whitespace changes
Inline
Side-by-side
Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISPreprocess.py
View file @
d627d12d
...
...
@@ -5,7 +5,7 @@
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
from
mantid.api
import
(
AlgorithmFactory
,
DataProcessorAlgorithm
,
MatrixWorkspaceProperty
,
WorkspaceGroup
)
from
mantid.api
import
(
AlgorithmFactory
,
DataProcessorAlgorithm
,
MatrixWorkspaceProperty
,
MatrixWorkspace
,
WorkspaceGroup
)
from
mantid.kernel
import
(
CompositeValidator
,
StringArrayLengthValidator
,
StringArrayMandatoryValidator
,
StringArrayProperty
,
Direction
)
from
mantid.simpleapi
import
LoadEventNexus
,
LoadNexus
...
...
@@ -61,12 +61,15 @@ class ReflectometryISISPreprocess(DataProcessorAlgorithm):
workspace
=
self
.
_loadRun
(
self
.
getPropertyValue
(
self
.
_RUNS
))
self
.
setProperty
(
self
.
_OUTPUT_WS
,
workspace
)
def
_loadRun
(
self
,
run
)
:
def
_loadRun
(
self
,
run
:
str
)
->
MatrixWorkspace
:
"""Load a run as an event workspace if slicing is requested, or a histogram
workspace otherwise. Transmission runs are always loaded as histogram workspaces."""
event_mode
=
self
.
getProperty
(
self
.
_EVENT_MODE
).
value
if
event_mode
:
ws
=
LoadEventNexus
(
Filename
=
run
,
LoadMonitors
=
True
,
StoreInADS
=
False
).
OutputWorkspace
alg
=
LoadEventNexus
(
Filename
=
run
,
LoadMonitors
=
True
,
StoreInADS
=
False
)
ws
=
alg
.
OutputWorkspace
# TODO
# monitors = alg.MonitorWorkspace
self
.
_validate_event_ws
(
ws
)
self
.
log
().
information
(
'Loaded event workspace'
)
else
:
...
...
Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISPreprocessTest.py
View file @
d627d12d
...
...
@@ -7,7 +7,7 @@
import
unittest
from
unittest
import
mock
from
mantid.api
import
IEventWorkspace
,
MatrixWorkspace
from
mantid.api
import
IEventWorkspace
,
MatrixWorkspace
,
WorkspaceGroup
from
mantid.simpleapi
import
CreateSampleWorkspace
,
ReflectometryISISPreprocess
...
...
@@ -45,6 +45,17 @@ class ReflectometryISISPreprocessTest(unittest.TestCase):
with
self
.
assertRaisesRegex
(
RuntimeError
,
"proton_charge"
):
ReflectometryISISPreprocess
(
**
args
)
@
mock
.
patch
(
"ReflectometryISISPreprocess.LoadEventNexus"
)
def
test_validation_of_event_workspace_group_throws
(
self
,
mocked_loader
):
args
=
{
'InputRunList'
:
'13460'
,
"EventMode"
:
True
,
"OutputWorkspace"
:
"ws"
}
ws
=
WorkspaceGroup
()
mocked_loader
.
return_value
.
OutputWorkspace
=
ws
with
self
.
assertRaisesRegex
(
RuntimeError
,
"Workspace Groups"
):
ReflectometryISISPreprocess
(
**
args
)
if
__name__
==
'__main__'
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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