diff --git a/scripts/Diffraction/isis_powder/routines/RunDetails.py b/scripts/Diffraction/isis_powder/routines/RunDetails.py index 03617eee6195f6e3716a77dc8891ffdebb8ffc86..56aa0bcb9d700cd96ad58447c3486126b4d21b49 100644 --- a/scripts/Diffraction/isis_powder/routines/RunDetails.py +++ b/scripts/Diffraction/isis_powder/routines/RunDetails.py @@ -68,7 +68,7 @@ def _get_customisable_attributes(cal_dict, inst_settings, empty_run_call, groupi grouping_name = inst_settings.grouping_file_name dict_to_return["grouping_file_name"] = grouping_name - dict_to_return["splined_van_name"] = common.generate_splined_name(vanadium_runs, append_list=splined_name_list) + dict_to_return["splined_van_name"] = common.generate_splined_name(vanadium_runs, splined_name_list) return dict_to_return diff --git a/scripts/Diffraction/isis_powder/routines/common.py b/scripts/Diffraction/isis_powder/routines/common.py index d4e05a7e8da543ce753241e12b8f0817be0481a9..a86676f10e833744dd0bbcea13f8d50c0292a00d 100644 --- a/scripts/Diffraction/isis_powder/routines/common.py +++ b/scripts/Diffraction/isis_powder/routines/common.py @@ -143,23 +143,22 @@ def generate_run_numbers(run_number_string): return run_list -def generate_splined_name(vanadium_string, append_list=None, *args): +def generate_splined_name(vanadium_string, *args): """ Generates a unique splined vanadium name which encapsulates any properties passed into this method so that the vanadium can be later loaded. :param vanadium_string: The name of this vanadium run :param args: Any identifying properties to append to the name - :param append_list: The args can also be passed as a list of values to append :return: The splined vanadium name """ out_name = "VanSplined" + '_' + str(vanadium_string) - for value in args: - out_name += '_' + str(value) - - if append_list: - for value in append_list: - out_name += '_' + str(value) + for passed_arg in args: + if isinstance(passed_arg, list): + for val in passed_arg: + out_name += '_' + str(val) + else: + out_name += '_' + str(passed_arg) out_name += ".nxs" return out_name diff --git a/scripts/test/ISISPowderCommonTest.py b/scripts/test/ISISPowderCommonTest.py index ab7fb70a435018833d31930e1de8a51f45ab8e6f..393c88cd74e12cb38d12c0145acafb739417865e 100644 --- a/scripts/test/ISISPowderCommonTest.py +++ b/scripts/test/ISISPowderCommonTest.py @@ -202,6 +202,36 @@ class ISISPowderCommonTest(unittest.TestCase): returned_values = common.generate_run_numbers(run_number_string=input_string) self.assertEqual(expected_values, returned_values) + def test_generate_spline_vanadium_name(self): + reference_vanadium_name = "foo_123" + sample_arg_one = "arg1" + sample_arg_two = 987 + + # Check that it correctly processes unnamed args + output = common.generate_splined_name(reference_vanadium_name, sample_arg_one, sample_arg_two) + expected_output = "VanSplined_" + reference_vanadium_name + '_' + sample_arg_one + '_' + str(sample_arg_two) + expected_output += '.nxs' + self.assertEqual(expected_output, output) + + # Check it can handle lists to append + sample_arg_list = ["bar", "baz", 567] + + expected_output = "VanSplined_" + reference_vanadium_name + for arg in sample_arg_list: + expected_output += '_' + str(arg) + expected_output += '.nxs' + output = common.generate_splined_name(reference_vanadium_name, sample_arg_list) + self.assertEqual(expected_output, output) + + # Check is can handle mixed inputs + expected_output = "VanSplined_" + reference_vanadium_name + '_' + sample_arg_one + for arg in sample_arg_list: + expected_output += '_' + str(arg) + expected_output += '_' + str(sample_arg_two) + '.nxs' + + output = common.generate_splined_name(reference_vanadium_name, sample_arg_one, sample_arg_list, sample_arg_two) + self.assertEqual(expected_output, output) + def test_generate_run_numbers_fails(self): run_input_sting = "text-string"