Skip to content

Commit

Permalink
Refs #9584 Add examples for CheckWorkspacesMatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Jackson committed Jun 5, 2014
1 parent e744125 commit a88f6fd
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions Code/Mantid/docs/source/algorithms/CheckWorkspacesMatch-v1.rst
Expand Up @@ -21,4 +21,55 @@ In the case of `EventWorkspaces <EventWorkspace>`__, they are checked to
hold identical event lists. Comparisons between an EventList and a
Workspace2D always fail.

Usage
-----

**Example - check that two workspaces are equal to one another:**

.. testcode:: ExCheckWorkspacesMatchSimple

dataX = [0,1,2,3,4,5,6,7,8,9]
dataY = [1,1,1,1,1,1,1,1,1]
ws1 = CreateWorkspace(dataX, dataY)

#create a copy of the workspace
ws2 = CloneWorkspace(ws1)

print CheckWorkspacesMatch(ws1, ws2)


Output:

.. testoutput:: ExCheckWorkspacesMatchSimple

Success!

**Example - check that two workspaces match within a certain tolerance:**

.. testcode:: ExCheckWorkspacesMatchTolerance

import numpy as np

#create a workspace with some simple data
dataX = range(0,20)
dataY1 = np.sin(dataX)
ws1 = CreateWorkspace(dataX, dataY1)

#create a similar workspace, but with added noise
dataY2 = np.sin(dataX) + 0.1*np.random.random_sample(len(dataX))
ws2 = CreateWorkspace(dataX, dataY2)

print CheckWorkspacesMatch(ws1, ws2) #fails, they're not the same
print CheckWorkspacesMatch(ws1, ws2, Tolerance=0.1) #passes, they're close enough


Output:

.. testoutput:: ExCheckWorkspacesMatchTolerance

Data mismatch
Success!


.. categories::

0 comments on commit a88f6fd

Please sign in to comment.