def test_that_save_workspace_to_file_can_set_file_types( self, mock_alg_manager): ws_name = "wsName" filename = "fileName" additional_run_numbers = {} file_types = [ SaveType.NEXUS, SaveType.CAN_SAS, SaveType.NX_CAN_SAS, SaveType.NIST_QXY, SaveType.RKH, SaveType.CSV ] save_workspace_to_file(ws_name, file_types, filename, additional_run_numbers) expected_options = { "InputWorkspace": ws_name, "Filename": filename, "Transmission": "", "TransmissionCan": "", "Nexus": True, "CanSAS": True, "NXcanSAS": True, "NistQxy": True, "RKH": True, "CSV": True } mock_alg_manager.assert_called_once_with("SANSSave", **expected_options)
def test_that_save_workspace_to_file_includes_run_numbers_in_options( self, mock_alg_manager): ws_name = "wsName" filename = "fileName" additional_run_numbers = { "SampleTransmissionRunNumber": "5", "SampleDirectRunNumber": "6", "CanScatterRunNumber": "7", "CanDirectRunNumber": "8" } save_workspace_to_file(ws_name, [], filename, additional_run_numbers) expected_options = { "InputWorkspace": ws_name, "Filename": filename, "Transmission": "", "TransmissionCan": "", "SampleTransmissionRunNumber": "5", "SampleDirectRunNumber": "6", "CanScatterRunNumber": "7", "CanDirectRunNumber": "8" } mock_alg_manager.assert_called_once_with("SANSSave", **expected_options)
def on_save_clicked(self): file_formats = self._view.get_save_options() if not file_formats: return selected_workspaces = self.get_workspaces() selected_filenames = self.get_filenames(selected_workspaces, self.filename) self._view.progress_bar_minimum = 0 self._view.progress_bar_maximum = len(selected_workspaces) self._view.progress_bar_value = 0 for name_to_save, filename in zip(selected_workspaces, selected_filenames): save_workspace_to_file(name_to_save, file_formats, filename) self._view.increment_progress()
def on_save_clicked(self): file_formats = self._view.get_save_options() if not file_formats: return selected_workspaces = self.get_workspaces() selected_filenames = self.get_filenames(selected_workspaces, self.filename) self._view.progress_bar_minimum = 0 self._view.progress_bar_maximum = len(selected_workspaces) self._view.progress_bar_value = 0 for name_to_save, filename in zip(selected_workspaces, selected_filenames): save_workspace_to_file(name_to_save, file_formats, filename) self._view.increment_progress()
def test_that_save_workspace_to_file_can_set_transmission_workspace_names(self, mock_alg_manager): ws_name = "wsName" filename = "fileName" additional_run_numbers = {} file_types = [] transmission_name = "transName" transmission_can_name = "transCanName" save_workspace_to_file(ws_name, file_types, filename, additional_run_numbers, transmission_name=transmission_name, transmission_can_name=transmission_can_name) expected_options = {"InputWorkspace": ws_name, "Filename": filename, "Transmission": transmission_name, "TransmissionCan": transmission_can_name} mock_alg_manager.assert_called_once_with("SANSSave", **expected_options)
def on_save_clicked(self): file_formats = self._view.get_save_options() if not file_formats: return selected_workspaces = self.get_workspaces() selected_filenames = self.get_filenames(selected_workspaces, self.filename) additional_run_numbers = {} self._view.progress_bar_minimum = 0 self._view.progress_bar_maximum = len(selected_workspaces) self._view.progress_bar_value = 0 for name_to_save, filename in zip(selected_workspaces, selected_filenames): try: save_workspace_to_file(name_to_save, file_formats, filename, additional_run_numbers) except RuntimeError: logger.warning( f"Cannot save {name_to_save} using SANSSave. " "This workspace needs to be the result of a SANS reduction, " "i.e. it can only be 1D or 2D if the second axis " "is numeric.") self._view.increment_progress()