Beispiel #1
0
 def test_that_does_not_delete_pms_which_are_not_sans(self):
     property_manager = self._get_property_manager()
     PropertyManagerDataService.addOrReplace("test", property_manager)
     pms = PropertyManagerService()
     pms.remove_sans_property_managers()
     self.assertEqual(len(PropertyManagerDataService.getObjectNames()), 1)
     self._remove_all_property_managers()
Beispiel #2
0
 def test_that_it_adds_nothing_when_empty_list_is_passed_in(self):
     pms = PropertyManagerService()
     number_of_elements_on_pmds_after = len(
         PropertyManagerDataService.getObjectNames())
     pms.add_states_to_pmds({})
     self.assertEqual(number_of_elements_on_pmds_after, 0)
     self._remove_all_property_managers()
Beispiel #3
0
 def test_that_add_states_to_pmds(self):
     self.assertEqual(len(PropertyManagerDataService.getObjectNames()), 0)
     states = {0: get_example_state(), 1: get_example_state()}
     pms = PropertyManagerService()
     pms.add_states_to_pmds(states)
     self.assertEqual(len(PropertyManagerDataService.getObjectNames()), 2)
     self._remove_all_property_managers()
 def test_that_add_states_to_pmds(self):
     self.assertTrue(len(PropertyManagerDataService.getObjectNames()) == 0)
     states = {0: get_example_state(), 1: get_example_state()}
     pms = PropertyManagerService()
     pms.add_states_to_pmds(states)
     self.assertTrue(len(PropertyManagerDataService.getObjectNames()) == 2)
     self._remove_all_property_managers()
 def test_that_does_not_delete_pms_which_are_not_sans(self):
     property_manager = self._get_property_manager()
     PropertyManagerDataService.addOrReplace("test", property_manager)
     pms = PropertyManagerService()
     pms.remove_sans_property_managers()
     self.assertTrue(len(PropertyManagerDataService.getObjectNames()) == 1)
     self._remove_all_property_managers()
    def PyExec(self):
        # 1. Get the index of the batch reduction
        index = self.getProperty("RowIndex").value

        if index == Property.EMPTY_INT:
            return

        # 2. Get the state for the index from the PropertyManagerDataService
        property_manager_service = PropertyManagerService()
        state = property_manager_service.get_single_state_from_pmds(
            index_to_retrieve=index)
        # 3. Get some global settings
        use_optimizations = self.getProperty("UseOptimizations").value
        output_mode_as_string = self.getProperty("OutputMode").value
        output_mode = OutputMode.from_string(output_mode_as_string)
        plot_results = self.getProperty('PlotResults').value
        output_graph = self.getProperty('OutputGraph').value

        # 3. Run the sans_batch script
        sans_batch = SANSBatchReduction()
        sans_batch(states=state,
                   use_optimizations=use_optimizations,
                   output_mode=output_mode,
                   plot_results=plot_results,
                   output_graph=output_graph)
Beispiel #7
0
    def on_processed_clicked(self):
        """
        Prepares the batch reduction.

        0. Validate rows and create dummy workspace if it does not exist
        1. Sets up the states
        2. Adds a dummy input workspace
        3. Adds row index information
        """

        try:
            self.sans_logger.information("Starting processing of batch table.")
            # 0. Validate rows
            self._create_dummy_input_workspace()
            self._validate_rows()

            # 1. Set up the states and convert them into property managers
            states = self.get_states()
            if not states:
                raise RuntimeError(
                    "There seems to have been an issue with setting the states. Make sure that a user file"
                    " has been loaded")
            property_manager_service = PropertyManagerService()
            property_manager_service.add_states_to_pmds(states)

            # 2. Add dummy input workspace to Options column
            self._remove_dummy_workspaces_and_row_index()
            self._set_dummy_workspace()

            # 3. Add dummy row index to Options column
            self._set_indices()
        except Exception as e:
            self._view.halt_process_flag()
            self.sans_logger.error("Process halted due to: {}".format(str(e)))
Beispiel #8
0
 def test_that_can_retrieve_states_from_pmds(self):
     self.assertEqual(len(PropertyManagerDataService.getObjectNames()), 0)
     states = {0: get_example_state(), 1: get_example_state()}
     pms = PropertyManagerService()
     pms.add_states_to_pmds(states)
     retrieved_states = pms.get_states_from_pmds()
     self.assertEqual(len(retrieved_states), 2)
     self.assertTrue(isinstance(retrieved_states[0], type(states[0])))
     self.assertEqual(len(PropertyManagerDataService.getObjectNames()), 2)
     self._remove_all_property_managers()
 def test_that_can_retrieve_states_from_pmds(self):
     self.assertTrue(len(PropertyManagerDataService.getObjectNames()) == 0)
     states = {0: get_example_state(), 1: get_example_state()}
     pms = PropertyManagerService()
     pms.add_states_to_pmds(states)
     retrieved_states = pms.get_states_from_pmds()
     self.assertTrue(len(retrieved_states) == 2)
     self.assertTrue(isinstance(retrieved_states[0], type(states[0])))
     self.assertTrue(len(PropertyManagerDataService.getObjectNames()) == 2)
     self._remove_all_property_managers()
    def PyExec(self):
        # 1. Get the index of the batch reduction
        index = self.getProperty("RowIndex").value

        if index == Property.EMPTY_INT:
            return

        # 2. Get the state for the index from the PropertyManagerDataService
        property_manager_service = PropertyManagerService()
        state = property_manager_service.get_single_state_from_pmds(index_to_retrieve=index)
        # 3. Get some global settings
        use_optimizations = self.getProperty("UseOptimizations").value
        output_mode_as_string = self.getProperty("OutputMode").value
        output_mode = OutputMode.from_string(output_mode_as_string)
        plot_results = self.getProperty('PlotResults').value
        output_graph = self.getProperty('OutputGraph').value

        # 3. Run the sans_batch script
        sans_batch = SANSBatchReduction()
        sans_batch(states=state, use_optimizations=use_optimizations, output_mode=output_mode, plot_results=plot_results
                   , output_graph=output_graph)
Beispiel #11
0
 def test_that_removes_sans_property_managers_from_pmds(self):
     self.assertTrue(len(PropertyManagerDataService.getObjectNames()) == 0)
     states = {0: get_example_state(), 1: get_example_state()}
     pms = PropertyManagerService()
     pms.add_states_to_pmds(states)
     pms.remove_sans_property_managers()
     self.assertTrue(len(PropertyManagerDataService.getObjectNames()) == 0)
     self._remove_all_property_managers()
Beispiel #12
0
 def test_that_it_returns_empty_list_if_no_states_have_been_added(self):
     pms = PropertyManagerService()
     states = pms.get_states_from_pmds()
     self.assertEqual(states, [])
     self._remove_all_property_managers()
 def test_that_it_returns_empty_list_if_no_states_have_been_added(self):
     pms = PropertyManagerService()
     states = pms.get_states_from_pmds()
     self.assertTrue(states == [])
     self._remove_all_property_managers()
 def test_that_it_adds_nothing_when_empty_list_is_passed_in(self):
     pms = PropertyManagerService()
     number_of_elements_on_pmds_after = len(PropertyManagerDataService.getObjectNames())
     pms.add_states_to_pmds({})
     self.assertTrue(number_of_elements_on_pmds_after == 0)
     self._remove_all_property_managers()