Skip to content
Snippets Groups Projects
Commit 8939f32f authored by Daniel Murphy's avatar Daniel Murphy
Browse files

Remove nested groups Add iterative deletion

parent 764e9844
No related branches found
No related tags found
No related merge requests found
...@@ -200,45 +200,31 @@ You can pass workspace groups into any algorithm and Mantid will run that algori ...@@ -200,45 +200,31 @@ You can pass workspace groups into any algorithm and Mantid will run that algori
# You can still of course refer to members of a group directly # You can still of course refer to members of a group directly
ws1 = Rebin(ws1, Params=100) ws1 = Rebin(ws1, Params=100)
Using Nested Workspace Groups
#############################
It is possible to have groups within groups, the inner group can simply be added to the outer group in the usual way. For example
.. code:: Final words of warning:
#######################
# create the following structure - It is best to add all workspaces to the ADS before configuring the grouping structure (as in the above code); otherwise you will only be able to name the top level group when you add the structure to the ADS. All the sub-groups and workspaces not already in the ADS will be given default names which you will then have to change manually, it is much easier to name them as you go (and putting them in the ADS is the only way to name them).
# group1/
# ws1
# ws2
# group2/
# ws3
# ws4
ws1 = CreateSampleWorkspace() - When iterating over a WorkspaceGroup to delete its workspaces, then iterate over a list, such as:
ws2 = CreateSampleWorkspace()
ws3 = CreateSampleWorkspace()
ws4 = CreateSampleWorkspace()
group1 = WorkspaceGroup() .. testcode:: Iterative Deletion of Grouped Workspaces
group2 = WorkspaceGroup()
mtd.add("group1", group1) for ws in list(wsGroup):
mtd.add("group2", group2) DeleteWorkspace(ws)
group1.add("ws1") otherwise indexing will be confused by each deletion.
group1.add("ws2")
group2.add("ws3")
group2.add("ws4")
group1.add("group2") - To Delete an entire group, just run:
Be careful when creating nested groups; every single group and workspace must have a unique name, if not workspaces with the same name will be overwritten. Do not try to group workspaces which are already in a group using `groupWorkspace` as this will create duplicate named workspaces in two groups; this will result in data being deleted without warning. Similarly don't try to create duplicate named workspaces and put them into different folders. .. testcode:: Delete Entire Workspace
One final note; it is best to add all workspaces to the ADS before configuring the grouping structure (as in the above code); otherwise you will only be able to name the top level group when you add the structure to the ADS. All the sub-groups and workspaces not already in the ADS will be given default names which you will then have to change manually, it is much easier to name them as you go (and putting them in the ADS is the only way to name them). DeleteWorkspace(wsGroup)
.. include:: WorkspaceNavigation.txt .. include:: WorkspaceNavigation.txt
.. categories:: Concepts .. categories:: Concepts
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment