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
01dff08f
Commit
01dff08f
authored
6 years ago
by
Gigg, Martyn Anthony
Browse files
Options
Downloads
Patches
Plain Diff
Replace _workspaces_from_names with new ADS method
Refs #0
parent
42d1ad89
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
qt/applications/workbench/workbench/plugins/workspacewidget.py
+5
-35
5 additions, 35 deletions
...plications/workbench/workbench/plugins/workspacewidget.py
with
5 additions
and
35 deletions
qt/applications/workbench/workbench/plugins/workspacewidget.py
+
5
−
35
View file @
01dff08f
...
@@ -21,7 +21,6 @@ import functools
...
@@ -21,7 +21,6 @@ import functools
# third-party library imports
# third-party library imports
from
mantid.api
import
AnalysisDataService
,
MatrixWorkspace
,
WorkspaceGroup
from
mantid.api
import
AnalysisDataService
,
MatrixWorkspace
,
WorkspaceGroup
from
mantid.kernel
import
Logger
from
mantidqt.dialogs.spectraselectordialog
import
get_spectra_selection
from
mantidqt.dialogs.spectraselectordialog
import
get_spectra_selection
from
mantidqt.widgets.workspacewidget.workspacetreewidget
import
WorkspaceTreeWidget
from
mantidqt.widgets.workspacewidget.workspacetreewidget
import
WorkspaceTreeWidget
from
qtpy.QtWidgets
import
QMessageBox
,
QVBoxLayout
from
qtpy.QtWidgets
import
QMessageBox
,
QVBoxLayout
...
@@ -31,38 +30,6 @@ from workbench.plugins.base import PluginWidget
...
@@ -31,38 +30,6 @@ from workbench.plugins.base import PluginWidget
from
workbench.plotting.figuretype
import
figure_type
,
FigureType
from
workbench.plotting.figuretype
import
figure_type
,
FigureType
from
workbench.plotting.functions
import
current_figure_or_none
,
pcolormesh
,
plot
from
workbench.plotting.functions
import
current_figure_or_none
,
pcolormesh
,
plot
LOGGER
=
Logger
(
b
"
workspacewidget
"
)
def
_workspaces_from_names
(
names
):
"""
Convert a list of workspace names to a list of MatrixWorkspace handles. Any WorkspaceGroup
encountered is flattened and its members inserted into the list at this point
Flattens any workspace groups with the list, preserving the order of the remaining elements
:param names: A list of workspace names
:return: A list where each element is a single MatrixWorkspace
"""
ads
=
AnalysisDataService
.
Instance
()
flat
=
[]
for
name
in
names
:
try
:
ws
=
ads
[
name
.
encode
(
'
utf-8
'
)]
except
KeyError
:
LOGGER
.
warning
(
"
Skipping {} as it does not exist
"
.
format
(
name
))
continue
if
isinstance
(
ws
,
MatrixWorkspace
):
flat
.
append
(
ws
)
elif
isinstance
(
ws
,
WorkspaceGroup
):
group_len
=
len
(
ws
)
for
i
in
range
(
group_len
):
flat
.
append
(
ws
[
i
])
else
:
LOGGER
.
warning
(
"
{} it is not a MatrixWorkspace or WorkspaceGroup.
"
.
format
(
name
))
return
flat
class
WorkspaceWidget
(
PluginWidget
):
class
WorkspaceWidget
(
PluginWidget
):
"""
Provides a Workspace Widget for workspace manipulation
"""
"""
Provides a Workspace Widget for workspace manipulation
"""
...
@@ -70,6 +37,8 @@ class WorkspaceWidget(PluginWidget):
...
@@ -70,6 +37,8 @@ class WorkspaceWidget(PluginWidget):
def
__init__
(
self
,
parent
):
def
__init__
(
self
,
parent
):
super
(
WorkspaceWidget
,
self
).
__init__
(
parent
)
super
(
WorkspaceWidget
,
self
).
__init__
(
parent
)
self
.
_ads
=
AnalysisDataService
.
Instance
()
# layout
# layout
self
.
workspacewidget
=
WorkspaceTreeWidget
()
self
.
workspacewidget
=
WorkspaceTreeWidget
()
layout
=
QVBoxLayout
()
layout
=
QVBoxLayout
()
...
@@ -116,7 +85,8 @@ class WorkspaceWidget(PluginWidget):
...
@@ -116,7 +85,8 @@ class WorkspaceWidget(PluginWidget):
return
return
try
:
try
:
selection
=
get_spectra_selection
(
_workspaces_from_names
(
names
),
self
)
workspaces
=
self
.
_ads
.
retrieveWorkspaces
(
names
,
unrollGroups
=
True
)
selection
=
get_spectra_selection
(
workspaces
,
self
)
if
selection
is
not
None
:
if
selection
is
not
None
:
plot
(
selection
.
workspaces
,
spectrum_nums
=
selection
.
spectra
,
plot
(
selection
.
workspaces
,
spectrum_nums
=
selection
.
spectra
,
wksp_indices
=
selection
.
wksp_indices
,
wksp_indices
=
selection
.
wksp_indices
,
...
@@ -132,7 +102,7 @@ class WorkspaceWidget(PluginWidget):
...
@@ -132,7 +102,7 @@ class WorkspaceWidget(PluginWidget):
:param names: A list of workspace names
:param names: A list of workspace names
"""
"""
try
:
try
:
pcolormesh
(
_workspaces_from_names
(
names
))
pcolormesh
(
self
.
_ads
.
retrieveWorkspaces
(
names
,
unrollGroups
=
True
))
except
BaseException
:
except
BaseException
:
import
traceback
import
traceback
traceback
.
print_exc
()
traceback
.
print_exc
()
...
...
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