def test_create_gui_state_from_userfile_adds_save_format_from_gui(self):
        gui_state = StateGuiModel({})
        gui_state.save_types = [SaveType.NXcanSAS]

        row_state = create_gui_state_from_userfile('MaskLOQData.txt', gui_state)

        self.assertEqual(gui_state.save_types, row_state.save_types)
 def test_that_can_set_transmission_roi_mask_and_radius(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.transmission_roi_files = "roi.xml"
     state_gui_model.transmission_mask_files = "mask.xml"
     state_gui_model.transmission_radius = 8.
     self.assertTrue(state_gui_model.transmission_roi_files == "roi.xml")
     self.assertTrue(state_gui_model.transmission_mask_files == "mask.xml")
     self.assertTrue(state_gui_model.transmission_radius == 8)
 def test_that_phi_mask_can_be_set(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.phi_limit_min = 12.
     state_gui_model.phi_limit_max = 13.
     state_gui_model.phi_limit_use_mirror = True
     self.assertTrue(state_gui_model.phi_limit_min == 12.)
     self.assertTrue(state_gui_model.phi_limit_max == 13.)
     self.assertTrue(state_gui_model.phi_limit_use_mirror)
 def test_that_can_set_normalize_to_monitor(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.normalization_incident_monitor = 2
     state_gui_model.normalization_interpolate = True
     self.assertTrue(state_gui_model.normalization_incident_monitor == 2)
     self.assertTrue(state_gui_model.normalization_interpolate)
     # Reassign
     state_gui_model.normalization_incident_monitor = 3
     self.assertTrue(state_gui_model.normalization_incident_monitor == 3)
 def test_that_can_set_transmission_monitor(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.transmission_incident_monitor = 2
     state_gui_model.transmission_interpolate = True
     self.assertTrue(state_gui_model.transmission_incident_monitor == 2)
     self.assertTrue(state_gui_model.transmission_interpolate)
     # # Reassign
     state_gui_model.transmission_incident_monitor = 3
     self.assertTrue(state_gui_model.transmission_incident_monitor == 3)
 def test_that_can_set_transmission_fit_options(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.transmission_sample_fit_type = FitType.Logarithmic
     state_gui_model.transmission_can_fit_type = FitType.Linear
     state_gui_model.transmission_sample_polynomial_order = 2
     state_gui_model.transmission_can_polynomial_order = 2
     self.assertTrue(state_gui_model.transmission_sample_fit_type is FitType.Logarithmic)
     self.assertTrue(state_gui_model.transmission_can_fit_type is FitType.Linear)
     self.assertTrue(state_gui_model.transmission_sample_polynomial_order == 2)
     self.assertTrue(state_gui_model.transmission_can_polynomial_order == 2)
 def test_that_adjustment_files_can_be_set(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.wavelength_adjustment_det_1 = "wav1.txt"
     state_gui_model.wavelength_adjustment_det_2 = "wav2.txt"
     state_gui_model.pixel_adjustment_det_1 = "pix1.txt"
     state_gui_model.pixel_adjustment_det_2 = "pix2.txt"
     self.assertTrue(state_gui_model.wavelength_adjustment_det_1 == "wav1.txt")
     self.assertTrue(state_gui_model.wavelength_adjustment_det_2 == "wav2.txt")
     self.assertTrue(state_gui_model.pixel_adjustment_det_1 == "pix1.txt")
     self.assertTrue(state_gui_model.pixel_adjustment_det_2 == "pix2.txt")
    def test_that_transmission_fit_wavelength_can_be_set(self):
        state_gui_model = StateGuiModel({"test": [1]})
        state_gui_model.transmission_sample_wavelength_min = 1.3
        state_gui_model.transmission_sample_wavelength_max = 10.3
        state_gui_model.transmission_can_wavelength_min = 1.3
        state_gui_model.transmission_can_wavelength_max = 10.3

        self.assertTrue(state_gui_model.transmission_sample_wavelength_min == 1.3)
        self.assertTrue(state_gui_model.transmission_sample_wavelength_max == 10.3)
        self.assertTrue(state_gui_model.transmission_can_wavelength_min == 1.3)
        self.assertTrue(state_gui_model.transmission_can_wavelength_max == 10.3)
    def test_that_can_set_the_q_limits(self):
        state_gui_model = StateGuiModel({"test": [1]})
        state_gui_model.q_1d_rebin_string = "test"
        state_gui_model.q_xy_max = 1.
        state_gui_model.q_xy_step = 122.
        state_gui_model.q_xy_step_type = RangeStepType.Log

        self.assertTrue(state_gui_model.q_1d_rebin_string == "test")
        self.assertTrue(state_gui_model.q_xy_max == 1.)
        self.assertTrue(state_gui_model.q_xy_step == 122.)
        self.assertTrue(state_gui_model.q_xy_step_type is RangeStepType.Log)
 def test_that_can_set_wavelength(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.wavelength_min = 1.
     state_gui_model.wavelength_max = 2.
     state_gui_model.wavelength_step = .5
     state_gui_model.wavelength_step_type = RangeStepType.Lin
     state_gui_model.wavelength_step_type = RangeStepType.Log
     self.assertTrue(state_gui_model.wavelength_min == 1.)
     self.assertTrue(state_gui_model.wavelength_max == 2.)
     self.assertTrue(state_gui_model.wavelength_step == .5)
     self.assertTrue(state_gui_model.wavelength_step_type is RangeStepType.Log)
    def test_that_can_set_and_reset_merged_settings(self):
        state_gui_model = StateGuiModel({DetectorId.shift_fit: [det_fit_range(start=1., stop=2., use_fit=True)],
                                         DetectorId.rescale_fit: [det_fit_range(start=1.4, stop=7., use_fit=False)],
                                         DetectorId.rescale: [12.],
                                         DetectorId.shift: [234.]})
        self.assertTrue(state_gui_model.merge_scale == 12.)
        self.assertTrue(state_gui_model.merge_shift == 234.)
        self.assertFalse(state_gui_model.merge_scale_fit)
        self.assertTrue(state_gui_model.merge_shift_fit)
        self.assertTrue(state_gui_model.merge_q_range_start == 1.)
        self.assertTrue(state_gui_model.merge_q_range_stop == 7.)

        state_gui_model.merge_scale = 12.3
        state_gui_model.merge_shift = 3.
        state_gui_model.merge_scale_fit = True
        state_gui_model.merge_shift_fit = False
        state_gui_model.merge_q_range_start = 2.
        state_gui_model.merge_q_range_stop = 8.

        self.assertTrue(state_gui_model.merge_scale == 12.3)
        self.assertTrue(state_gui_model.merge_shift == 3.)
        self.assertTrue(state_gui_model.merge_scale_fit)
        self.assertFalse(state_gui_model.merge_shift_fit)
        self.assertTrue(state_gui_model.merge_q_range_start == 2.)
        self.assertTrue(state_gui_model.merge_q_range_stop == 8.)
 def test_that_can_set_the_sample_geometry(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.sample_width = 1.2
     state_gui_model.sample_height = 1.6
     state_gui_model.sample_thickness = 1.8
     state_gui_model.z_offset = 1.78
     state_gui_model.sample_shape = SampleShape.Cuboid
     self.assertTrue(state_gui_model.sample_width == 1.2)
     self.assertTrue(state_gui_model.sample_height == 1.6)
     self.assertTrue(state_gui_model.sample_thickness == 1.8)
     self.assertTrue(state_gui_model.z_offset == 1.78)
     self.assertTrue(state_gui_model.sample_shape is SampleShape.Cuboid)
Exemple #13
0
 def test_that_gravity_extra_length_empty_by_default_and_usage_true_by_default(self):
     state_gui_model = StateGuiModel({"test": [1]})
     self.assertTrue(state_gui_model.gravity_on_off)
     self.assertEqual(state_gui_model.gravity_extra_length, "")
 def test_that_can_set_compatibility_mode(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.compatibility_mode = True
     self.assertTrue(state_gui_model.compatibility_mode)
Exemple #15
0
 def test_that_default_compatibility_mode_is_true(self):
     state_gui_model = StateGuiModel({"test": [1]})
     self.assertTrue(state_gui_model.compatibility_mode)
 def test_that_is_set_to_2D_reduction(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.reduction_dimensionality = ReductionDimensionality.TwoDim
     self.assertTrue(state_gui_model.reduction_dimensionality is ReductionDimensionality.TwoDim)
Exemple #17
0
 def test_that_phi_mask_defaults_to_90_and_true_for_use_mirror(self):
     state_gui_model = StateGuiModel({"test": [1]})
     self.assertEqual(state_gui_model.phi_limit_min, "-90")
     self.assertEqual(state_gui_model.phi_limit_max, "90")
     self.assertTrue(state_gui_model.phi_limit_use_mirror)
Exemple #18
0
 def test_that_can_select_multiple_save_types(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.save_types = [SaveType.RKH, SaveType.NXcanSAS]
     self.assertEqual(state_gui_model.save_types, [SaveType.RKH, SaveType.NXcanSAS])
Exemple #19
0
 def test_that_default_save_type_is_NXcanSAS(self):
     state_gui_model = StateGuiModel({"test": [1]})
     self.assertEqual(state_gui_model.save_types, [SaveType.NXcanSAS])
Exemple #20
0
 def test_that_can_zero_error_free_saving_can_be_changed(self):
     state_gui_model = StateGuiModel({OtherId.save_as_zero_error_free: [True]})
     state_gui_model.zero_error_free = False
     self.assertFalse(state_gui_model.zero_error_free)
Exemple #21
0
 def test_that_can_zero_error_free_saving_is_default(self):
     state_gui_model = StateGuiModel({"test": [1]})
     self.assertTrue(state_gui_model.zero_error_free)
Exemple #22
0
 def test_that_mask_file_can_be_set(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.mask_files = ["file.txt", "file2.txt"]
     self.assertEqual(state_gui_model.mask_files, ["file.txt", "file2.txt"])
Exemple #23
0
 def test_that_mask_file_defaults_are_empty(self):
     state_gui_model = StateGuiModel({"test": [1]})
     self.assertEqual(state_gui_model.mask_files, [])
Exemple #24
0
 def test_that_can_set_event_slice_optimisation(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.event_slice_optimisation = True
     self.assertTrue(state_gui_model.event_slice_optimisation)
Exemple #25
0
 def test_that_radius_mask_defaults_to_empty(self):
     state_gui_model = StateGuiModel({"test": [1]})
     self.assertEqual(state_gui_model.radius_limit_min, "")
     self.assertEqual(state_gui_model.radius_limit_max, "")
Exemple #26
0
 def test_that_if_no_slice_event_is_present_an_empty_string_is_returned(self):
     state_gui_model = StateGuiModel({"test": 1})
     self.assertEqual(state_gui_model.event_slices, "")
 def test_that_mask_file_can_be_set(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.mask_files = ["file.txt", "file2.txt"]
     self.assertTrue(state_gui_model.mask_files == ["file.txt", "file2.txt"])
Exemple #28
0
 def test_that_slice_event_can_be_retrieved_if_it_exists(self):
     state_gui_model = StateGuiModel({OtherId.event_slices: [event_binning_string_values(value="test")]})
     self.assertEqual(state_gui_model.event_slices, "test")
 def test_that_can_update_reduction_dimensionality(self):
     state_gui_model = StateGuiModel({OtherId.reduction_dimensionality: [ReductionDimensionality.OneDim]})
     self.assertTrue(state_gui_model.reduction_dimensionality is ReductionDimensionality.OneDim)
     state_gui_model.reduction_dimensionality = ReductionDimensionality.TwoDim
     self.assertTrue(state_gui_model.reduction_dimensionality is ReductionDimensionality.TwoDim)
Exemple #30
0
 def test_that_slice_event_can_be_updated(self):
     state_gui_model = StateGuiModel({OtherId.event_slices: [event_binning_string_values(value="test")]})
     state_gui_model.event_slices = "test2"
     self.assertEqual(state_gui_model.event_slices, "test2")
 def test_that_merge_min_can_be_set(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.merge_min = 78.9
     self.assertTrue(state_gui_model.merge_min == 78.9)
Exemple #32
0
 def test_that_is_1D_reduction_by_default(self):
     state_gui_model = StateGuiModel({"test": [1]})
     self.assertEqual(state_gui_model.reduction_dimensionality, ReductionDimensionality.OneDim)
Exemple #33
0
 def test_that_is_set_to_2D_reduction(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.reduction_dimensionality = ReductionDimensionality.TwoDim
     self.assertEqual(state_gui_model.reduction_dimensionality, ReductionDimensionality.TwoDim)
 def _get_state_gui_model():
     user_file_path = create_user_file(sample_user_file)
     adapter = UserFileReaderAdapter(file_information=None,
                                     user_file_name=user_file_path)
     return StateGuiModel(adapter.get_all_states(file_information=None))
 def test_that_can_set_absolute_scale(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.absolute_scale = .5
     self.assertTrue(state_gui_model.absolute_scale == .5)
Exemple #36
0
 def test_that_can_set_compatibility_mode(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.compatibility_mode = False
     self.assertFalse(state_gui_model.compatibility_mode)
Exemple #37
0
 def test_that_can_set_gravity(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.gravity_on_off = False
     state_gui_model.gravity_extra_length = 1.
     self.assertFalse(state_gui_model.gravity_on_off)
     self.assertEqual(state_gui_model.gravity_extra_length, 1.)
 def test_that_transmission_mn_shift_can_be_set(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.transmission_mn_shift = 234
     self.assertTrue(state_gui_model.transmission_mn_shift == 234)
 def test_that_can_set_only_transmission_interpolation(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.transmission_interpolate = True
     self.assertTrue(state_gui_model.transmission_incident_monitor is None)
     self.assertTrue(state_gui_model.transmission_interpolate)
Exemple #40
0
 def test_that_radius_mask_can_be_set(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.radius_limit_min = 12.
     state_gui_model.radius_limit_max = 13.
     self.assertEqual(state_gui_model.radius_limit_min, 12.)
     self.assertEqual(state_gui_model.radius_limit_max, 13.)
 def test_that_transmission_monitor_can_be_set(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.transmission_monitor = 4
     self.assertTrue(state_gui_model.transmission_monitor == 4)
 def test_that_can_set_gravity(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.gravity_on_off = False
     state_gui_model.gravity_extra_length = 1.
     self.assertFalse(state_gui_model.gravity_on_off)
     self.assertTrue(state_gui_model.gravity_extra_length == 1.)
 def test_that_can_zero_error_free_saving_can_be_changed(self):
     state_gui_model = StateGuiModel({OtherId.save_as_zero_error_free: [True]})
     state_gui_model.zero_error_free = False
     self.assertFalse(state_gui_model.zero_error_free)
Exemple #44
0
    def test_that_q_resolution_can_be_set_correctly(self):
        state_gui_model = StateGuiModel({"test": [1]})
        state_gui_model.use_q_resolution = True
        state_gui_model.q_resolution_source_a = 1.5
        state_gui_model.q_resolution_sample_a = 2.5
        state_gui_model.q_resolution_source_h = 1.5
        state_gui_model.q_resolution_sample_h = 2.5
        state_gui_model.q_resolution_source_w = 1.5
        state_gui_model.q_resolution_sample_w = 2.5
        state_gui_model.q_resolution_collimation_length = 1.7
        state_gui_model.q_resolution_delta_r = 12.4
        state_gui_model.q_resolution_moderator_file = "test.txt"

        self.assertTrue(state_gui_model.use_q_resolution)
        self.assertEqual(state_gui_model.q_resolution_source_a, 1.5)
        self.assertEqual(state_gui_model.q_resolution_sample_a, 2.5)
        self.assertEqual(state_gui_model.q_resolution_source_h, 1.5)
        self.assertEqual(state_gui_model.q_resolution_sample_h, 2.5)
        self.assertEqual(state_gui_model.q_resolution_source_w, 1.5)
        self.assertEqual(state_gui_model.q_resolution_sample_w, 2.5)
        self.assertEqual(state_gui_model.q_resolution_collimation_length, 1.7)
        self.assertEqual(state_gui_model.q_resolution_delta_r, 12.4)
        self.assertEqual(state_gui_model.q_resolution_moderator_file, "test.txt")
 def test_that_event_binning_default_settings_are_emtpy(self):
     state_gui_model = StateGuiModel({"test": [1]})
     self.assertTrue(state_gui_model.event_binning == "")
Exemple #46
0
 def test_that_default_event_slice_optimisation_is_false(self):
     state_gui_model = StateGuiModel({"test": [1]})
     self.assertFalse(state_gui_model.event_slice_optimisation)
 def test_that_can_set_show_transmission(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.show_transmission = True
     self.assertTrue(state_gui_model.show_transmission)
 def test_that_event_binning_can_be_set(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.event_binning = "1,-1,10"
     self.assertTrue(state_gui_model.event_binning == "1,-1,10")
 def test_that_can_select_multiple_save_types(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.save_types = [SaveType.RKH, SaveType.NXcanSAS]
     self.assertTrue(state_gui_model.save_types == [SaveType.RKH, SaveType.NXcanSAS])
 def test_that_is_set_to_lab_by_default(self):
     state_gui_model = StateGuiModel({"test": [1]})
     self.assertTrue(
         state_gui_model.reduction_mode is ISISReductionMode.LAB)
    def test_that_q_resolution_can_be_set_correctly(self):
        state_gui_model = StateGuiModel({"test": [1]})
        state_gui_model.use_q_resolution = True
        state_gui_model.q_resolution_source_a = 1.5
        state_gui_model.q_resolution_sample_a = 2.5
        state_gui_model.q_resolution_source_h = 1.5
        state_gui_model.q_resolution_sample_h = 2.5
        state_gui_model.q_resolution_source_w = 1.5
        state_gui_model.q_resolution_sample_w = 2.5
        state_gui_model.q_resolution_collimation_length = 1.7
        state_gui_model.q_resolution_delta_r = 12.4
        state_gui_model.q_resolution_moderator_file = "test.txt"

        self.assertTrue(state_gui_model.use_q_resolution)
        self.assertTrue(state_gui_model.q_resolution_source_a == 1.5)
        self.assertTrue(state_gui_model.q_resolution_sample_a == 2.5)
        self.assertTrue(state_gui_model.q_resolution_source_h == 1.5)
        self.assertTrue(state_gui_model.q_resolution_sample_h == 2.5)
        self.assertTrue(state_gui_model.q_resolution_source_w == 1.5)
        self.assertTrue(state_gui_model.q_resolution_sample_w == 2.5)
        self.assertTrue(state_gui_model.q_resolution_collimation_length == 1.7)
        self.assertTrue(state_gui_model.q_resolution_delta_r == 12.4)
        self.assertTrue(state_gui_model.q_resolution_moderator_file == "test.txt")
 def test_that_can_be_set_to_something_else(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.reduction_mode = ISISReductionMode.Merged
     self.assertTrue(
         state_gui_model.reduction_mode is ISISReductionMode.Merged)
 def test_that_radius_mask_can_be_set(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.radius_limit_min = 12.
     state_gui_model.radius_limit_max = 13.
     self.assertTrue(state_gui_model.radius_limit_min == 12.)
     self.assertTrue(state_gui_model.radius_limit_max == 13.)
 def red_mode_wrapper():
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.reduction_mode = "string"
 def test_that_slice_event_can_be_updated(self):
     state_gui_model = StateGuiModel({OtherId.event_slices: [event_binning_string_values(value="test")]})
     state_gui_model.event_slices = "test2"
     self.assertTrue(state_gui_model.event_slices == "test2")
 def test_that_default_wavelength_settings_are_empty(self):
     state_gui_model = StateGuiModel({"test": [1]})
     self.assertTrue(not state_gui_model.wavelength_min)
     self.assertTrue(not state_gui_model.wavelength_max)
     self.assertTrue(not state_gui_model.wavelength_step)
 def red_dim_wrapper():
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.reduction_dimensionality = "string"
 def test_that_default_wavelength_step_type_is_linear(self):
     state_gui_model = StateGuiModel({"test": [1]})
     self.assertTrue(
         state_gui_model.wavelength_step_type is RangeStepType.Lin)
 def test_that_merge_mask_can_be_set_to_something_else(self):
     state_gui_model = StateGuiModel({"test": [1]})
     state_gui_model.merge_mask = True
     self.assertTrue(state_gui_model.merge_mask)
Exemple #60
0
 def test_that_default_sample_shape_is_cylinder_axis_up(self):
     state_gui_model = StateGuiModel({"test": [1]})
     self.assertEqual(state_gui_model.sample_shape, None)