Skip to content
Snippets Groups Projects
Commit dce57694 authored by Elliot Oram's avatar Elliot Oram
Browse files

Merge pull request #14101 from mantidproject/14082_Add_System_Test_Spline_Smoothing

System Test for SplineSmoothing algorithm
parents a171b174 f60a7da6
No related merge requests found
60bb50b5937fc35c4b4794cfc2c94956
# pylint: disable=no-init,attribute-defined-outside-init,too-many-public-methods
import stresstesting
from mantid.simpleapi import *
from mantid.api import *
import unittest
DIFF_PLACES = 7
class SplineSmoothingTest(stresstesting.MantidStressTest):
def requiredFiles(self):
return set(["Stheta.nxs", "ENGINX_precalculated_vanadium_run000236516_bank_curves.nxs"])
def runTest(self):
self._success = False
wsenginx = Load("ENGINX_precalculated_vanadium_run000236516_bank_curves")
SplineSmoothing(InputWorkspace=wsenginx, OutputWorkspace="enginxOutSpline", MaxNumberOfBreaks=20)
# MaxNumberOfBreaks=0, maximum number of breaking points possible
wsstheta = Load("Stheta")
SplineSmoothing(InputWorkspace=wsstheta, OutputWorkspace="SthetaOutSpline")
self._success = True
# Custom code to create and run this single test suite
# and then mark as success or failure
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(LoadTests, "test"))
runner = unittest.TextTestRunner()
# Run using either runner
res = runner.run(suite)
if res.wasSuccessful():
self._success = True
else:
self._success = False
def validate(self):
return self._success
# ======================================================================
# work horse
class LoadTests(unittest.TestCase):
wsname = "__LoadTest"
cleanup_names = []
def tearDown(self):
self.cleanup_names.append(self.wsname)
for name in self.cleanup_names:
try:
AnalysisDataService.remove(name)
except KeyError:
pass
self.cleanup_names = []
# ============================ Success ==============================
def runTest(self):
wsenginx = Load("ENGINX_precalculated_vanadium_run000236516_bank_curves")
SplineSmoothing(InputWorkspace=wsenginx, MaxNumberOfBreaks=50)
# MaxNumberOfBreaks=0, maximum number of breaking points possible
wsstheta = Load("Stheta")
SplineSmoothing(InputWorkspace=wsstheta, OutputWorkspace="SthetaOutSpline")
def test_enginx_curve_spline_smoothed(self):
ws_smooth = mtd['enginxOutSpline']
# SplineSmooth all three spectrum
self.assertEquals(3, ws_smooth.getNumberHistograms())
self.assertEquals(14168, ws_smooth.blocksize())
self.assertAlmostEqual(0.24360103, ws_smooth.readX(2)[0], places=DIFF_PLACES)
self.assertAlmostEqual(0.86546920, ws_smooth.readX(2)[1738], places=DIFF_PLACES)
self.assertAlmostEqual(57.1213842, ws_smooth.readY(2)[0], places=DIFF_PLACES)
def test_stheta_curve_spline_smoothed(self):
ws_smooth = mtd['SthetaOutSpline']
# SplineSmooth all three spectrum
self.assertEquals(1, ws_smooth.getNumberHistograms())
self.assertEquals(463, ws_smooth.blocksize())
self.assertAlmostEqual(2.3405, ws_smooth.readX(0)[0], places=DIFF_PLACES)
self.assertAlmostEqual(56.9972, ws_smooth.readX(0)[231], places=DIFF_PLACES)
def test_enginx_curve_further_checks(self):
ws_smooth_enginx = mtd['enginxOutSpline']
ws_enginx = mtd['wsenginx']
ws_smooth_stetha = mtd['SthetaOutSpline']
ws_stetha = mtd['wsStheta']
for i in range(0, 462):
self.assertTrue(ws_enginx.readX(0)[i], ws_smooth_enginx.readX(0)[i])
self.assertTrue(ws_stetha.readX(0)[i], ws_smooth_stetha.readX(0)[i])
self.assertTrue(ws_stetha.readY(0)[i], ws_smooth_stetha.readY(0)[i])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment