Skip to content

Commit

Permalink
vanadium inputs added, all tests working but some too slow, re #12426
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeMPouzols committed Jul 15, 2015
1 parent 38f0d8b commit 428db36
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class EnggCalibrateTest(unittest.TestCase):

_data_ws = None
_van_ws = None

# Note not using @classmethod setUpClass / tearDownClass because that's not supported in the old
# unittest of rhel6
Expand All @@ -15,6 +16,9 @@ def setUp(self):
if not self.__class__._data_ws:
self.__class__._data_ws = LoadNexus("ENGINX00228061.nxs", OutputWorkspace='ENGIN-X_test_ws')

if not self.__class__._van_ws:
self.__class__._van_ws = LoadNexus("ENGINX00236516.nxs", OutputWorkspace='ENGIN-X_test_vanadium_ws')

def test_issues_with_properties(self):
"""
Tests proper error handling when passing wrong properties or not passing required
Expand Down Expand Up @@ -65,7 +69,8 @@ def test_runs_ok(self):
"""

difc, zero = EnggCalibrate(InputWorkspace=self.__class__._data_ws,
ExpectedPeaks=[1.6, 1.1, 1.8], Bank='2')
VanadiumWorkspace=self.__class__._van_ws,
ExpectedPeaks=[1.6, 1.1, 1.8], Bank='2')

self.check_3peaks_values(difc, zero)

Expand All @@ -77,19 +82,20 @@ def test_runs_ok_with_peaks_file(self):
# This file has: 1.6, 1.1, 1.8 (as the test above)
filename = 'EnginX_3_expected_peaks_unittest.csv'
difc, zero = EnggCalibrate(InputWorkspace=self.__class__._data_ws,
ExpectedPeaks=[-4, 40, 323], # nonsense, but FromFile should prevail
ExpectedPeaksFromFile=filename,
Bank='2')
VanadiumWorkspace=self.__class__._van_ws,
ExpectedPeaks=[-4, 40, 323], # nonsense, but FromFile should prevail
ExpectedPeaksFromFile=filename,
Bank='2')

self.check_3peaks_values(difc, zero)

def check_3peaks_values(self, difc, zero):
# There are platform specific differences in final parameter values
# For example, debian: 369367.57492582797; win7: 369242.28850305633
expected_difc = 369367.57492582797
# For example in earlier versions, debian: 369367.57492582797; win7: 369242.28850305633
expected_difc = 19110.7598121
# assertLess would be nices, but only available in unittest >= 2.7
self.assertTrue(abs((expected_difc-difc)/expected_difc) < 5e-3)
expected_zero = -223297.87349744083
expected_zero = -724.337353801
self.assertTrue(abs((expected_zero-zero)/expected_zero) < 5e-3)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
class EnggFocusTest(unittest.TestCase):

_data_ws = None
_van_ws = None

_expected_yvals_bank1 = [0.0037582279159681957, 0.00751645583194, 0.0231963801368,
0.0720786940576, 0.0615909620868, 0.00987979301753]
_expected_yvals_bank1 = [0.016676032919961604, 0.015995344072536975, 0.047449159145519233,
0.15629648148139513, 0.11018845452876322, 0.017291707350351286]

_expected_yvals_bank2 = [0, 0.0112746837479, 0.0394536605073, 0.0362013481777,
0.0728500403862, 0.000870882282987]
_expected_yvals_bank2 = [0.0, 0.018310873111703541, 0.071387646720910913,
0.061783574337739511, 0.13102948781549345, 0.001766956921862095]

# Note not using @classmethod setUpClass / tearDownClass because that's not supported in the old
# unittest of rhel6
Expand All @@ -21,6 +22,9 @@ def setUp(self):
if not self.__class__._data_ws:
self.__class__._data_ws = LoadNexus("ENGINX00228061.nxs", OutputWorkspace='ENGIN-X_test_ws')

if not self.__class__._van_ws:
self.__class__._van_ws = LoadNexus("ENGINX00236516.nxs", OutputWorkspace='ENGIN-X_test_vanadium_ws')

def test_wrong_properties(self):
"""
Tests proper error handling when passing wrong properties or not passing
Expand Down Expand Up @@ -105,7 +109,9 @@ def test_runs_ok(self):
"""

out_name = 'out'
out = EnggFocus(InputWorkspace=self.__class__._data_ws, VanadiumWorkspace=self.__class__._data_ws, Bank='1', OutputWorkspace=out_name)
out = EnggFocus(InputWorkspace=self.__class__._data_ws,
VanadiumWorkspace=self.__class__._van_ws,
Bank='1', OutputWorkspace=out_name)

self._check_output_ok(ws=out, ws_name=out_name, y_dim_max=1, yvalues=self._expected_yvals_bank1)

Expand All @@ -115,7 +121,9 @@ def test_runs_ok_south(self):
"""

out_name = 'out'
out = EnggFocus(InputWorkspace=self.__class__._data_ws, Bank='North', OutputWorkspace=out_name)
out = EnggFocus(InputWorkspace=self.__class__._data_ws,
VanadiumWorkspace=self.__class__._van_ws,
Bank='North', OutputWorkspace=out_name)

self._check_output_ok(ws=out, ws_name=out_name, y_dim_max=1, yvalues=self._expected_yvals_bank1)

Expand All @@ -124,8 +132,10 @@ def test_runs_ok_indices(self):
Same as above but with detector (workspace) indices equivalent to bank 1
"""
out_idx_name = 'out_idx'
out_idx = EnggFocus(InputWorkspace=self.__class__._data_ws, SpectrumNumbers='1-1200',
OutputWorkspace=out_idx_name)
out_idx = EnggFocus(InputWorkspace=self.__class__._data_ws,
VanadiumWorkspace=self.__class__._van_ws,
SpectrumNumbers='1-1200',
OutputWorkspace=out_idx_name)
self._check_output_ok(ws=out_idx, ws_name=out_idx_name, y_dim_max=1,
yvalues=self._expected_yvals_bank1)

Expand All @@ -135,8 +145,9 @@ def test_runs_ok_indices_split3(self):
"""
out_idx_name = 'out_idx'
out_idx = EnggFocus(InputWorkspace=self.__class__._data_ws,
SpectrumNumbers='1-100, 101-500, 400-1200',
OutputWorkspace=out_idx_name)
VanadiumWorkspace=self.__class__._van_ws,
SpectrumNumbers='1-100, 101-500, 400-1200',
OutputWorkspace=out_idx_name)
self._check_output_ok(ws=out_idx, ws_name=out_idx_name, y_dim_max=1,
yvalues=self._expected_yvals_bank1)

Expand All @@ -147,7 +158,8 @@ def test_runs_ok_bank2(self):

out_name = 'out_bank2'
out_bank2 = EnggFocus(InputWorkspace=self.__class__._data_ws, Bank='2',
OutputWorkspace=out_name)
VanadiumWorkspace=self.__class__._van_ws,
OutputWorkspace=out_name)

self._check_output_ok(ws=out_bank2, ws_name=out_name, y_dim_max=1201,
yvalues=self._expected_yvals_bank2)
Expand All @@ -157,8 +169,9 @@ def test_runs_ok_bank_south(self):
As before but using the Bank='South' alias. Should produce the same results.
"""
out_name = 'out_bank_south'
out_bank_south = EnggFocus(InputWorkspace=self.__class__._data_ws, Bank='South',
OutputWorkspace=out_name)
out_bank_south = EnggFocus(InputWorkspace=self.__class__._data_ws,
VanadiumWorkspace=self.__class__._van_ws,
Bank='South', OutputWorkspace=out_name)

self._check_output_ok(ws=out_bank_south, ws_name=out_name, y_dim_max=1201,
yvalues=self._expected_yvals_bank2)
Expand Down

0 comments on commit 428db36

Please sign in to comment.