From 7e1e61266f50a01ab522d511dd55406d753f52e9 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Tue, 21 Oct 2014 15:07:36 +0100 Subject: [PATCH] Modified system test for new MolDyn algorithm Seperate general Ascii laoder tests from simulation specific loader tests Refs #10391 --- .../ISISIndirectLoadAsciiTest.py | 80 ++---------------- .../ISISIndirectSimulationTest.py | 78 +++++++++++++++++ ...s => ISISIndirectSimulation_MolDynCDL.nxs} | Bin ... ISISIndirectSimulation_MolDynCDL_SQW.nxs} | Bin ...s => ISISIndirectSimulation_MolDynDAT.nxs} | Bin 5 files changed, 84 insertions(+), 74 deletions(-) create mode 100644 SystemTests/AnalysisTests/ISISIndirectSimulationTest.py rename SystemTests/AnalysisTests/ReferenceResults/{ISISIndirectLoadAscii_MolDynCDL.nxs => ISISIndirectSimulation_MolDynCDL.nxs} (100%) rename SystemTests/AnalysisTests/ReferenceResults/{ISISIndirectLoadAscii_MolDynCDL_SQW.nxs => ISISIndirectSimulation_MolDynCDL_SQW.nxs} (100%) rename SystemTests/AnalysisTests/ReferenceResults/{ISISIndirectLoadAscii_MolDynDAT.nxs => ISISIndirectSimulation_MolDynDAT.nxs} (100%) diff --git a/SystemTests/AnalysisTests/ISISIndirectLoadAsciiTest.py b/SystemTests/AnalysisTests/ISISIndirectLoadAsciiTest.py index 27046c3..2a030a3 100644 --- a/SystemTests/AnalysisTests/ISISIndirectLoadAsciiTest.py +++ b/SystemTests/AnalysisTests/ISISIndirectLoadAsciiTest.py @@ -6,7 +6,7 @@ class IN10SiliconTest(stresstesting.MantidStressTest): def runTest(self): - import IndirectNeutron as Main + import IndirectNeutron as Main instr = 'IN10' ana = 'silicon' @@ -18,7 +18,7 @@ def runTest(self): saveOp = False plotOp = False Main.InxStart(instr,run,ana,refl,rejectZ,useM,'',verbOp,plotOp,saveOp) - + def validate(self): self.tolerance = 1e-2 self.disableChecking.append("Instrument") @@ -28,7 +28,7 @@ def validate(self): class IN13CaFTest(stresstesting.MantidStressTest): def runTest(self): - import IndirectNeutron as Main + import IndirectNeutron as Main instr = 'IN13' ana = 'CaF' @@ -40,7 +40,7 @@ def runTest(self): saveOp = False plotOp = False Main.IN13Start(instr,run,ana,refl,rejectZ,useM,'',verbOp,plotOp,saveOp) - + def validate(self): self.tolerance = 1e-2 @@ -65,7 +65,7 @@ def checkWorkspacesMatch(self, ws1, ws2): checker.setPropertyValue("Workspace2", ws2) checker.setPropertyValue("Tolerance", str(self.tolerance)) checker.setPropertyValue("CheckInstrument","0") - + checker.execute() if checker.getPropertyValue("Result") != 'Success!': @@ -78,7 +78,7 @@ def checkWorkspacesMatch(self, ws1, ws2): #==================================================================================================== class IN16SiliconTest(stresstesting.MantidStressTest): - + def runTest(self): import IndirectNeutron as Main @@ -99,71 +99,3 @@ def validate(self): self.disableChecking.append("Instrument") return 'IN16_65722_silicon111_red', 'ISISIndirectLoadAscii_IN16SiliconTest.nxs' - -#==================================================================================================== -class MolDynCdlTest(stresstesting.MantidStressTest): - - def runTest(self): - from IndirectMolDyn import MolDynImport - - filename = 'DISF_NaF.cdl' - funcNames = 'Fqt-total,Sqw-total' - verbOp = True - saveOp = False - plotOp = False - - MolDynImport(filename,funcNames,verbOp,plotOp,saveOp) - - def validate(self): - self.tolerance = 1e-2 - self.disableChecking.append("Instrument") - - from mantid.simpleapi import Load - - Load(Filename='ISISIndirectLoadAscii_MolDynCDL.nxs',OutputWorkspace='ISISIndirectLoadAscii_MolDynCDL') - Load(Filename='ISISIndirectLoadAscii_MolDynCDL_SQW.nxs',OutputWorkspace='ISISIndirectLoadAscii_MolDynCDL_SQW') - - # check each of the resulting workspaces match - ws1Match = self.checkWorkspacesMatch('DISF_NaF_Fqt-total', 'ISISIndirectLoadAscii_MolDynCDL') - ws2Match = self.checkWorkspacesMatch('DISF_NaF_Sqw-total', 'ISISIndirectLoadAscii_MolDynCDL_SQW') - - return ( ws1Match and ws2Match ) - - # function to check two workspaces match - # Used when the result of a test produces more than a single workspace - def checkWorkspacesMatch(self, ws1, ws2): - from mantid.simpleapi import SaveNexus, AlgorithmManager - checker = AlgorithmManager.create("CheckWorkspacesMatch") - checker.setLogging(True) - checker.setPropertyValue("Workspace1", ws1) - checker.setPropertyValue("Workspace2", ws2) - checker.setPropertyValue("Tolerance", str(self.tolerance)) - checker.setPropertyValue("CheckInstrument","0") - - checker.execute() - - if checker.getPropertyValue("Result") != 'Success!': - print self.__class__.__name__ - SaveNexus(InputWorkspace=ws2,Filename=self.__class__.__name__+'-mismatch.nxs') - return False - - return True - -#==================================================================================================== -class MolDynDatTest(stresstesting.MantidStressTest): - - def runTest(self): - from IndirectMolDyn import MolDynText - - filename = 'WSH_test.dat' - verbOp = True - saveOp = False - plotOp = False - - MolDynText(filename,verbOp,plotOp,saveOp) - - def validate(self): - self.tolerance = 1e-2 - self.disableChecking.append("Instrument") - - return 'WSH_test_iqt', 'ISISIndirectLoadAscii_MolDynDAT.nxs' diff --git a/SystemTests/AnalysisTests/ISISIndirectSimulationTest.py b/SystemTests/AnalysisTests/ISISIndirectSimulationTest.py new file mode 100644 index 0000000..8d20845 --- /dev/null +++ b/SystemTests/AnalysisTests/ISISIndirectSimulationTest.py @@ -0,0 +1,78 @@ +import stresstesting +import os +from mantid.simpleapi import * + +#==================================================================================================== +class MolDynCdlTest(stresstesting.MantidStressTest): + + def runTest(self): + from mantid.simpleapi import MolDyn + + MolDyn(Filename='DISF_NaF.cdl', + Functions=['Fqt-total', 'Sqw-total'], + Verbose=True, + Plot='None', + Save=False, + OutputWorkspace='ISISIndirectSimulationTest_MolDynCdl') + + + def validate(self): + self.tolerance = 1e-2 + self.disableChecking.append("Instrument") + + from mantid.simpleapi import Load + + Load(Filename='ISISIndirectSimulation_MolDynCDL.nxs',OutputWorkspace='ISISIndirectSimulation_MolDynCDL') + Load(Filename='ISISIndirectSimulation_MolDynCDL_SQW.nxs',OutputWorkspace='ISISIndirectSimulation_MolDynCDL_SQW') + + # check each of the resulting workspaces match + ws1Match = self.checkWorkspacesMatch('DISF_NaF_Fqt-total', 'ISISIndirectSimulation_MolDynCDL') + ws2Match = self.checkWorkspacesMatch('DISF_NaF_Sqw-total', 'ISISIndirectSimulation_MolDynCDL_SQW') + + return ( ws1Match and ws2Match ) + + + def checkWorkspacesMatch(self, ws1, ws2): + """ + Function to check two workspaces match + Used when the result of a test produces more than a single workspace + """ + + from mantid.simpleapi import SaveNexus, AlgorithmManager + + checker = AlgorithmManager.create("CheckWorkspacesMatch") + checker.setLogging(True) + checker.setPropertyValue("Workspace1", ws1) + checker.setPropertyValue("Workspace2", ws2) + checker.setPropertyValue("Tolerance", str(self.tolerance)) + checker.setPropertyValue("CheckInstrument","0") + + checker.execute() + + if checker.getPropertyValue("Result") != 'Success!': + print self.__class__.__name__ + SaveNexus(InputWorkspace=ws2,Filename=self.__class__.__name__+'-mismatch.nxs') + return False + + return True + + +#==================================================================================================== +class MolDynDatTest(stresstesting.MantidStressTest): + + def runTest(self): + from mantid.simpleapi import MolDyn + + MolDyn(Filename='WSH_test.dat', + Verbose=True, + Plot='None', + Save=False, + OutputWorkspace='WSH_test_iqt') + + + def validate(self): + self.tolerance = 1e-2 + self.disableChecking.append("Instrument") + + return 'WSH_test_iqt', 'ISISIndirectSimulation_MolDynDAT.nxs' + diff --git a/SystemTests/AnalysisTests/ReferenceResults/ISISIndirectLoadAscii_MolDynCDL.nxs b/SystemTests/AnalysisTests/ReferenceResults/ISISIndirectSimulation_MolDynCDL.nxs similarity index 100% rename from SystemTests/AnalysisTests/ReferenceResults/ISISIndirectLoadAscii_MolDynCDL.nxs rename to SystemTests/AnalysisTests/ReferenceResults/ISISIndirectSimulation_MolDynCDL.nxs diff --git a/SystemTests/AnalysisTests/ReferenceResults/ISISIndirectLoadAscii_MolDynCDL_SQW.nxs b/SystemTests/AnalysisTests/ReferenceResults/ISISIndirectSimulation_MolDynCDL_SQW.nxs similarity index 100% rename from SystemTests/AnalysisTests/ReferenceResults/ISISIndirectLoadAscii_MolDynCDL_SQW.nxs rename to SystemTests/AnalysisTests/ReferenceResults/ISISIndirectSimulation_MolDynCDL_SQW.nxs diff --git a/SystemTests/AnalysisTests/ReferenceResults/ISISIndirectLoadAscii_MolDynDAT.nxs b/SystemTests/AnalysisTests/ReferenceResults/ISISIndirectSimulation_MolDynDAT.nxs similarity index 100% rename from SystemTests/AnalysisTests/ReferenceResults/ISISIndirectLoadAscii_MolDynDAT.nxs rename to SystemTests/AnalysisTests/ReferenceResults/ISISIndirectSimulation_MolDynDAT.nxs