Skip to content

Commit

Permalink
Merge pull request mantidproject#36155 from ConorMFinn/36070_wsgroup_…
Browse files Browse the repository at this point in the history
…docs

Include Imports Required to Run Scripts in Workspace Group Docs
  • Loading branch information
SilkeSchomann authored Sep 21, 2023
2 parents d071255 + 981fc5b commit a19d3ec
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/source/concepts/WorkspaceGroup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Workspace groups can be created in a more flexible way in the Python script wind

.. testcode:: CreatingWorkspaceGroups

from mantid.simpleapi import *

ws1 = CreateSampleWorkspace()
ws2 = CreateSampleWorkspace()
ws3 = CreateSampleWorkspace()
Expand Down Expand Up @@ -70,8 +72,11 @@ the group should then appear in the ADS with the given name. Using direct instan

.. testcode:: CreatingWorkspaceGroupsInstantiated

from mantid.simpleapi import *
from mantid.api import WorkspaceGroup

mtd.clear()

ws1 = CreateSampleWorkspace()
ws2 = CreateSampleWorkspace()
ws3 = CreateSampleWorkspace()
Expand All @@ -97,8 +102,11 @@ Alternatively, workspace group objects can be fed workspaces which are not in th

.. testcode:: CreatingWorkspaceGroupsNoADS

from mantid.simpleapi import *
from mantid.api import WorkspaceGroup

mtd.clear()

ws1 = WorkspaceFactory.create("Workspace2D", 2, 2, 2)
ws2 = WorkspaceFactory.create("Workspace2D", 2, 2, 2)
ws3 = WorkspaceFactory.create("Workspace2D", 2, 2, 2)
Expand Down Expand Up @@ -135,6 +143,7 @@ If you want to check if a variable points to something that is a Workspace Group

.. testcode:: CheckGroupWorkspace

from mantid.simpleapi import *
from mantid.api import WorkspaceGroup

ws1 = CreateSampleWorkspace()
Expand All @@ -156,6 +165,8 @@ Looping over all of the members of a group

.. testcode:: GroupWorkspaceMembers

from mantid.simpleapi import *

ws1 = CreateSampleWorkspace()
ws2 = CreateSampleWorkspace()
wsGroup = GroupWorkspaces("ws1,ws2")
Expand Down Expand Up @@ -186,6 +197,8 @@ You can pass workspace groups into any algorithm and Mantid will run that algori

.. testcode:: CheckGroupWorkspace

from mantid.simpleapi import *

ws1 = CreateSampleWorkspace()
ws2 = CreateSampleWorkspace()
wsGroup = GroupWorkspaces("ws1,ws2")
Expand All @@ -211,6 +224,8 @@ Final words of warning:

.. testcode:: Iterative Deletion of Grouped Workspaces

from mantid.simpleapi import *

ws1 = CreateSampleWorkspace()
ws2 = CreateSampleWorkspace()
wsGroup = GroupWorkspaces("ws1,ws2")
Expand All @@ -224,6 +239,8 @@ otherwise indexing will be confused by each deletion.

.. testcode:: Delete Entire Workspace

from mantid.simpleapi import *

ws1 = CreateSampleWorkspace()
ws2 = CreateSampleWorkspace()
wsGroup = GroupWorkspaces("ws1,ws2")
Expand Down

0 comments on commit a19d3ec

Please sign in to comment.