Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #9342 Add unit test for SofQWMoments
- Loading branch information
Samuel Jackson
committed
Jun 10, 2014
1 parent
381ecde
commit dd13091
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
Code/Mantid/Framework/PythonInterface/test/python/plugins/algorithms/SofQWMomentsTest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import unittest | ||
from mantid.simpleapi import SofQWMoments, CreateSampleWorkspace, ScaleX, RenameWorkspace, LoadInstrument, SofQW | ||
from mantid import mtd | ||
|
||
class SofQWMomentsTest(unittest.TestCase): | ||
|
||
def createSampleWorkspace(self): | ||
""" Create a dummy workspace that looks like a sample run""" | ||
#create a dummy workspace | ||
function = "name=Lorentzian,Amplitude=1,PeakCentre=5,FWHM=1" | ||
ws = CreateSampleWorkspace("Histogram", Function="User Defined", UserDefinedFunction=function, XMin=0, XMax=10, BinWidth=0.01, XUnit="DeltaE") | ||
ws = ScaleX(ws, -5, "Add") #shift to center on 0 | ||
ws = ScaleX(ws, 0.1) #scale to size | ||
LoadInstrument(ws, InstrumentName='IRIS') | ||
return ws | ||
|
||
def test_sofqwmoments(self): | ||
ws = self.createSampleWorkspace() | ||
|
||
#Run SofQW and then SofQWMoments | ||
ws = SofQW(ws, '0.4, 0.1, 1.8', EMode='Indirect', EFixed='1.845') | ||
ws = SofQWMoments(ws) | ||
|
||
workspaces = ws.getNames() | ||
self.assertEquals(len(workspaces), 4) | ||
|
||
for wsname in workspaces: | ||
ws = mtd[wsname] | ||
self.assertEquals(ws.getNumberHistograms(), 1) | ||
self.assertEquals(ws.blocksize(), 14) | ||
|
||
if __name__=="__main__": | ||
unittest.main() |