Esempio n. 1
0
 def __init__(self, parent_presenter, beam_centre_model=None):
     self._view = None
     self._parent_presenter = parent_presenter
     self._logger = Logger("SANS")
     self._beam_centre_model = BeamCentreModel(
     ) if not beam_centre_model else beam_centre_model
     self._worker = BeamCentreAsync(parent_presenter=self)
Esempio n. 2
0
 def __init__(self, parent_presenter):
     super(BeamCentrePresenter, self).__init__()
     self._view = None
     self._parent_presenter = parent_presenter
     self._work_handler = WorkHandler()
     self._logger = Logger("SANS")
     self._beam_centre_model = BeamCentreModel()
Esempio n. 3
0
 def __init__(self,
              parent_presenter,
              SANSCentreFinder,
              work_handler=None,
              beam_centre_model=None):
     self._view = None
     self._parent_presenter = parent_presenter
     self._work_handler = WorkHandler(
     ) if not work_handler else work_handler
     self._logger = Logger("SANS")
     self._beam_centre_model = BeamCentreModel(
         SANSCentreFinder) if not beam_centre_model else beam_centre_model
Esempio n. 4
0
    def test_that_model_initialises_with_correct_values(self):
        beam_centre_model = BeamCentreModel()

        self.assertEqual(beam_centre_model.max_iterations, 10)
        self.assertEqual(beam_centre_model.r_min, 60)
        self.assertEqual(beam_centre_model.r_max, 280)
        self.assertEqual(beam_centre_model.left_right, True)
        self.assertEqual(beam_centre_model.up_down, True)
        self.assertEqual(beam_centre_model.tolerance, 0.000125)
        self.assertEqual(beam_centre_model.lab_pos_1, '')
        self.assertEqual(beam_centre_model.lab_pos_2, '')
        self.assertEqual(beam_centre_model.hab_pos_2, '')
        self.assertEqual(beam_centre_model.hab_pos_1, '')
        self.assertEqual(beam_centre_model.scale_1, 1000)
        self.assertEqual(beam_centre_model.scale_2, 1000)
    def test_that_find_beam_centre_initiates_centre_finder_with_correct_parameters(
            self, centre_finder_mock):
        state = mock.MagicMock()
        beam_centre_model = BeamCentreModel()
        beam_centre_model.lab_pos_1 = 0.1
        beam_centre_model.lab_pos_2 = -0.1
        find_direction = FindDirectionEnum.All

        find_beam_centre(state, beam_centre_model)

        centre_finder_mock.return_value.called_once_with(
            state,
            r_min=beam_centre_model.r_min,
            r_max=beam_centre_model.r_max,
            max_iter=beam_centre_model.max_iterations,
            x_start=beam_centre_model.lab_pos_1,
            y_start=beam_centre_model.lab_pos_2,
            tolerance=beam_centre_model.tolerance,
            find_direction=find_direction,
            reduction_method=True)
Esempio n. 6
0
    def test_that_correct_values_are_set_for_LOQ(self):
        beam_centre_model = BeamCentreModel()
        beam_centre_model.reset_to_defaults_for_instrument(SANSInstrument.LOQ)

        self.assertEqual(beam_centre_model.r_max, 200)
Esempio n. 7
0
    def test_that_correct_values_are_set_for_LARMOR(self):
        beam_centre_model = BeamCentreModel()
        beam_centre_model.reset_to_defaults_for_instrument(
            SANSInstrument.LARMOR)

        self.assertEqual(beam_centre_model.scale_1, 1.0)
Esempio n. 8
0
    def test_that_can_update_model_values(self):
        beam_centre_model = BeamCentreModel()
        beam_centre_model.scale_2 = 1.0

        self.assertEqual(beam_centre_model.scale_2, 1.0)
Esempio n. 9
0
 def setUp(self):
     self.result = {'pos1': 300, 'pos2': -300}
     self.centre_finder_instance = mock.MagicMock(return_value=self.result)
     self.SANSCentreFinder = mock.MagicMock(
         return_value=self.centre_finder_instance)
     self.beam_centre_model = BeamCentreModel(self.SANSCentreFinder)