diff --git a/Code/Mantid/docs/source/algorithms/ChangeBinOffset-v1.rst b/Code/Mantid/docs/source/algorithms/ChangeBinOffset-v1.rst index 5a15eddb1561401e4449a235953d449ea5197ccb..719de26d666e62bb57c7bb7c9ebc34db66a003fc 100644 --- a/Code/Mantid/docs/source/algorithms/ChangeBinOffset-v1.rst +++ b/Code/Mantid/docs/source/algorithms/ChangeBinOffset-v1.rst @@ -20,4 +20,32 @@ selectively using the IndexMin and IndexMax properties. The output workspace will be an exact copy of the input workspace except for the changed time bins. +Usage +----- + +.. testcode:: ExOffset + + import numpy as np + + # Create a workspace + ws = CreateSampleWorkspace() + + # Offset the time bins by 1.0 + wsOffset = ChangeBinOffset(ws,Offset=1.0) + + # Check the offset + x1 = ws.readX(0) + x2 = wsOffset.readX(0) + # Test that all elements of arrays x2 and x1 differ by 1.0 + print np.all( x2 - x1 == 1.0 ) + y1 = ws.readY(0) + y2 = wsOffset.readY(0) + # Test that arrays y2 and y1 are equal + print np.all( y2 == y1 ) + +.. testoutput:: ExOffset + + True + True + .. categories:: diff --git a/Code/Mantid/docs/source/algorithms/SplineBackground-v1.rst b/Code/Mantid/docs/source/algorithms/SplineBackground-v1.rst index 58a1a2cf4229aebd196f70cd1959d1dc4b8f6a70..728dbe08189e3f21f74825165753fd0fb4b0e628 100644 --- a/Code/Mantid/docs/source/algorithms/SplineBackground-v1.rst +++ b/Code/Mantid/docs/source/algorithms/SplineBackground-v1.rst @@ -22,19 +22,26 @@ Usage import numpy as np # Create a workspace with some data + + # Fill array x with 100 float values equally spaced in the interval [-10, 10] x = np.linspace(-10,10,100) + # Fill array y with values of a function for each number in array x. y has the same length as x y = 1.0 / (x**2 + 10) + # Create array e of the same length as x and fill it with ones (1.0) e = np.ones_like(x) + # Uses the above arrays to create a workspace ws = CreateWorkspace( x, y, e ) # Run algorithm with low number of spline coefficients out = SplineBackground(ws, WorkspaceIndex=0, NCoeff=4) yout = out.readY(0) + # Sum the squares of the differences of elements of arrays y and yout print 'Fit quality is',np.sum( (y - yout)**2 ) # Increase the number of spline coefficients out = SplineBackground(ws, WorkspaceIndex=0, NCoeff=20) yout = out.readY(0) + # Sum the squares of the differences of elements of arrays y and yout print 'Fit quality is',np.sum( (y - yout)**2 ) .. testoutput:: ExampleSpline