Skip to content
Snippets Groups Projects
Commit 14695567 authored by Federico Montesino Pouzols's avatar Federico Montesino Pouzols
Browse files

Merge pull request #16296 from mantidproject/16097_LoadVesuvio_SpecList_validation

Vesuvio - LoadVesuvio spectrumlist parsing
parents c1e09997 585d9f25
No related merge requests found
......@@ -162,7 +162,10 @@ class LoadVesuvio(LoadEmptyVesuvio):
# Validate SpectrumList
grp_spectra_list = self.getProperty(SPECTRA_PROP).value
if ";" in grp_spectra_list:
if "," in grp_spectra_list:
# Split on ',' if in form of 2-3,6-7
grp_spectra_list = grp_spectra_list.split(",")
elif ";" in grp_spectra_list:
# Split on ';' if in form of 2-3;6-7
grp_spectra_list = grp_spectra_list.split(";")
else:
......@@ -176,9 +179,6 @@ class LoadVesuvio(LoadEmptyVesuvio):
spectra_list = spectra_grp.split("-")
# Validate format
issues = self._validate_range_formatting(spectra_list[0], spectra_list[1], SPECTRA_PROP, issues)
elif "," in spectra_grp:
# Split comma separated lists
spectra_list = spectra_grp.split(",")
else:
# Single spectra (put into list for use in loop)
spectra_list = [spectra_grp]
......
......@@ -20,7 +20,34 @@ class VesuvioTests(unittest.TestCase):
if monitor_name in mtd:
mtd.remove(monitor_name)
#==================== Test spectrum list validation ============================
def test_spectrum_list_single_range(self):
diff_mode = "DoubleDifference"
self._run_load("14188", "10-20", diff_mode)
# check workspace created
self.assertTrue(mtd.doesExist(self.ws_name))
def test_spectrum_list_comma_separated_list(self):
diff_mode = "DoubleDifference"
self._run_load("14188", "10,20,30,40", diff_mode)
# check workspace created
self.assertTrue(mtd.doesExist(self.ws_name))
def test_spectrum_list_comma_separated_ranges(self):
diff_mode = "DoubleDifference"
self._run_load("14188", "10-20;30-40", diff_mode, do_size_check=False)
# check workspace created
self.assertTrue(mtd.doesExist(self.ws_name))
#================== Success cases ================================
def test_load_with_back_scattering_spectra_produces_correct_workspace_using_double_difference(self):
diff_mode = "DoubleDifference"
self._run_load("14188", "3-134", diff_mode)
......@@ -287,7 +314,7 @@ class VesuvioTests(unittest.TestCase):
self.assertAlmostEqual(sigma_gauss, 52.3, places=tol_places)
self.assertAlmostEqual(hwhm_lorentz, 141.2, places=tol_places)
def _run_load(self, runs, spectra, diff_opt, ip_file="", sum_runs=False, load_mon=False):
def _run_load(self, runs, spectra, diff_opt, ip_file="", sum_runs=False, load_mon=False, do_size_check=True):
ms.LoadVesuvio(Filename=runs,OutputWorkspace=self.ws_name,
SpectrumList=spectra,Mode=diff_opt,InstrumentParFile=ip_file,
SumSpectra=sum_runs, LoadMonitors=load_mon)
......@@ -309,8 +336,9 @@ class VesuvioTests(unittest.TestCase):
return len(elements)
else:
return 1
if do_size_check:
self._do_size_check(self.ws_name, expected_size())
self._do_size_check(self.ws_name, expected_size())
loaded_data = mtd[self.ws_name]
if "Difference" in diff_opt:
self.assertTrue(not loaded_data.isHistogramData())
......
......@@ -93,6 +93,7 @@ Bugfixes
- The mini plot range bars in all interfaces now automatically update when a file is loaded.
- In the *I(Q, t) Fit* interface, checking the plot guess check box now correctly adds and removes the curve from the plot
- In the *BayesQuasi* interface ResNorm files are now automatically loaded from file locations when entered.
- :ref:`LoadVesuvio <algm-LoadVesuvio>` now correctly parses input in the form 10-20,30-40,50-60
`Full list of changes on GitHub <http://github.com/mantidproject/mantid/pulls?q=is%3Apr+milestone%3A%22Release+3.7%22+is%3Amerged+label%3A%22Component%3A+Indirect+Inelastic%22>`_
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