Skip to content

Commit

Permalink
Refs #9568. RenameWorkspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbekasov committed Jun 6, 2014
1 parent 26df43b commit ce51745
Showing 1 changed file with 73 additions and 4 deletions.
77 changes: 73 additions & 4 deletions Code/Mantid/docs/source/algorithms/RenameWorkspaces-v1.rst
Expand Up @@ -16,13 +16,82 @@ RenameWorkspace as a child algorithm having defined the output workspace
appropriately.

If run on a group workspace, the members of the group will be renamed in
the same manner as done by RemameWorkspace.
the same manner as done by RenameWorkspace.

The new names can be either explicitly defined by a comma separated list
or by adding a prefix, suffix or both a prefix and suffix.

**Warning:** No new name can be the same as any existing workspace, even
if that existing workspace is also being renamed. Duplicate names may
cause the loss of a workspace.
.. warning::

No new name can be the same as any existing workspace, even if that
existing workspace is also being renamed. Duplicate names may cause
the loss of a workspace.

Usage
-----

**Example - New names:**

.. testcode:: ExNewNames

# Make sure there is nothing in the ADS before we begin
mtd.clear()

names = ['ws1', 'ws2', 'ws3']

# Create some dummy workspaces
for name in names:
CreateWorkspace([0], [0], OutputWorkspace=name)

print 'Workspaces in the ADS _before_ renaming:', mtd.getObjectNames()

RenameWorkspaces(names, WorkspaceNames=['new_ws1', 'new_ws2', 'new_ws3'])

print 'Workspaces in the ADS _after_ renaming:', mtd.getObjectNames()

.. testcleanup:: ExNewNames

DeleteWorkspace('new_ws1')
DeleteWorkspace('new_ws2')
DeleteWorkspace('new_ws3')

Output:

.. testoutput:: ExNewNames

Workspaces in the ADS _before_ renaming: ['ws1', 'ws2', 'ws3']
Workspaces in the ADS _after_ renaming: ['new_ws1', 'new_ws2', 'new_ws3']

**Example - Using prefix and suffix:**

.. testcode:: ExPrefixAndSuffix

# Make sure there is nothing in the ADS before we begin
mtd.clear()

names = ['ws1', 'ws2', 'ws3']

# Create some dummy workspaces
for name in names:
CreateWorkspace([0], [0], OutputWorkspace=name)

print 'Workspaces in the ADS _before_ renaming:', mtd.getObjectNames()

RenameWorkspaces(names, Prefix='new_', Suffix='_name')

print 'Workspaces in the ADS _after_ renaming:', mtd.getObjectNames()

.. testcleanup:: ExPrefixAndSuffix

DeleteWorkspace('new_ws1_name')
DeleteWorkspace('new_ws2_name')
DeleteWorkspace('new_ws3_name')

Output:

.. testoutput:: ExPrefixAndSuffix

Workspaces in the ADS _before_ renaming: ['ws1', 'ws2', 'ws3']
Workspaces in the ADS _after_ renaming: ['new_ws1_name', 'new_ws2_name', 'new_ws3_name']

.. categories::

0 comments on commit ce51745

Please sign in to comment.