"...common/src/QtPropertyBrowser/qtpropertymanager.cpp" did not exist on "adc3e629dd0abab41c503136cd801cdf9e0ab7d0"
Newer
Older
"""
These system tests are to verify the behaviour of the ISIS reflectometry reduction scripts
"""
from __future__ import (absolute_import, division, print_function)
import stresstesting
from mantid.simpleapi import *
from abc import ABCMeta, abstractmethod
from six import with_metaclass
class LoadAndCheckBase(with_metaclass(ABCMeta, stresstesting.MantidStressTest)):
__comparison_out_workspace_name = 'a_integrated'
@abstractmethod
def get_raw_workspace_filename(self):
"""Returns the name of the raw workspace file"""
raise NotImplementedError("Implement get_raw_workspace_filename")
@abstractmethod
def get_nexus_workspace_filename(self):
"""Returns the name of the nexus workspace file"""
raise NotImplementedError("Implement get_nexus_workspace_filename")
@abstractmethod
def get_expected_instrument_name(self):
"""Returns the name of the instrument"""
raise NotImplementedError("Implement get_expected_instrument_name")
def get_expected_number_of_periods(self):
return 1
def get_integrated_reference_workspace_filename(self):
"""Returns the name of the benchmark file used for end-of-test comparison."""
if self.enable_reference_result_checking():
# Must have a reference result file if reference result checking is required
raise NotImplementedError("Implement get_nexus_workspace_filename")
def enable_reference_result_checking(self):
return True
def enable_instrument_checking(self):
def do_check_workspace_shape(self, ws1, ws2):
self.assertTrue(ws1.getNumberHistograms(), ws2.getNumberHistograms())
self.assertTrue(len(ws1.readX(0)) == len(ws2.readX(0)))
self.assertTrue(len(ws1.readY(0)) == len(ws2.readY(0)))
def do_check_instrument_applied(self, ws1, ws2):
instrument_name = self.get_expected_instrument_name()
self.assertTrue(ws1.getInstrument().getName() == instrument_name)
self.assertTrue(ws2.getInstrument().getName() == instrument_name)
def runTest(self):
Load(Filename=self.get_nexus_workspace_filename(), OutputWorkspace='nexus')
Load(Filename=self.get_raw_workspace_filename(), OutputWorkspace='raw')
a = mtd['nexus']
b = mtd['raw']
n_periods = self.get_expected_number_of_periods()
#raise NotImplementedError()
if isinstance(a,mantid.api.WorkspaceGroup):
self.assertEqual(a.size(), b.size())
self.assertEqual(a.size(), n_periods)
# Loop through each workspace in the group and apply some simple comaprison checks.
for i in range(0, a.size()):
self.do_check_workspace_shape(a[i], b[i])
if self.enable_instrument_checking():
self.do_check_instrument_applied(a[a.size()-1], b[b.size()-1])
if self.enable_reference_result_checking():
Integration(InputWorkspace=a[0], OutputWorkspace=self.__comparison_out_workspace_name)
else:
self.do_check_workspace_shape(a, b)
if self.enable_instrument_checking():
if self.enable_reference_result_checking():
Integration(InputWorkspace=a, OutputWorkspace=self.__comparison_out_workspace_name)
def validate(self):
self.disableChecking.append('Instrument')
if self.enable_reference_result_checking():
return self.__comparison_out_workspace_name, self.get_integrated_reference_workspace_filename()
else:
return True