• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python test_director.TestDirector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sans.test_helper.test_director.TestDirector的典型用法代码示例。如果您正苦于以下问题:Python TestDirector类的具体用法?Python TestDirector怎么用?Python TestDirector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TestDirector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_that_cross_block_masking_is_applied

    def test_that_cross_block_masking_is_applied(self):
        # Arrange
        data_builder = get_data_builder(SANSFacility.ISIS)
        data_builder.set_sample_scatter("SANS2D00028827")
        data_info = data_builder.build()

        mask_builder = get_mask_builder(data_info)

        # Expected_spectra
        expected_spectra = []

        # Block
        # Detector-specific cross block
        # The block will be evaluated for SANS2D on the LAB as:
        block_cross_horizontal = [12, 17]
        block_cross_vertical = [49, 67]
        for h, v in zip(block_cross_horizontal, block_cross_vertical):
            expected_spectra.extend([h*512 + 9 + v])

        mask_builder.set_LAB_block_cross_horizontal(block_cross_horizontal)
        mask_builder.set_LAB_block_cross_vertical(block_cross_vertical)
        mask_info = mask_builder.build()

        test_director = TestDirector()
        test_director.set_states(data_state=data_info, mask_state=mask_info)
        state = test_director.construct()

        workspace = self._load_workspace(state)

        # Act
        workspace = self._run_mask(state, workspace, "LAB")

        # Assert
        self._do_assert(workspace, expected_spectra)
开发者ID:DanNixon,项目名称:mantid,代码行数:34,代码来源:SANSMaskWorkspaceTest.py


示例2: test_that_divide_uses_settings_from_workspace

    def test_that_divide_uses_settings_from_workspace(self):
        # Arrange
        facility = SANSFacility.ISIS
        data_builder = get_data_builder(facility)
        data_builder.set_sample_scatter("SANS2D00022024")
        data_state = data_builder.build()

        scale_builder = get_scale_builder(data_state)
        scale_state = scale_builder.build()

        test_director = TestDirector()
        test_director.set_states(scale_state=scale_state, data_state=data_state)
        state = test_director.construct()

        divide_factory = DivideByVolumeFactory()
        divider = divide_factory.create_divide_by_volume(state)

        # Apply the settings from the SANS2D00022024 workspace
        width = 8.
        height = 8.
        thickness = 1.
        shape = 3

        workspace = ScaleHelperTest._get_workspace(width, height, thickness, shape)

        # Act
        output_workspace = divider.divide_by_volume(workspace, scale_state)

        # Assert
        expected_volume = thickness * math.pi * math.pow(width, 2) / 4.0
        expected_value = 0.3 / expected_volume
        data_y = output_workspace.dataY(0)
        self.assertEqual(data_y[0], expected_value)
开发者ID:DanNixon,项目名称:mantid,代码行数:33,代码来源:scale_helper_test.py


示例3: test_that_divide_uses_settings_from_state_if_they_are_set

    def test_that_divide_uses_settings_from_state_if_they_are_set(self):
        # Arrange
        facility = SANSFacility.ISIS
        data_builder = get_data_builder(facility)
        data_builder.set_sample_scatter("SANS2D00022024")
        data_state = data_builder.build()

        scale_builder = get_scale_builder(data_state)
        width = 10.
        height = 5.
        thickness = 2.
        scale_builder.set_shape(SampleShape.CylinderAxisAlong)
        scale_builder.set_thickness(thickness)
        scale_builder.set_width(width)
        scale_builder.set_height(height)
        scale_state = scale_builder.build()

        test_director = TestDirector()
        test_director.set_states(scale_state=scale_state, data_state=data_state)
        state = test_director.construct()

        divide_factory = DivideByVolumeFactory()
        divider = divide_factory.create_divide_by_volume(state)

        workspace = ScaleHelperTest._get_workspace()

        # Act
        output_workspace = divider.divide_by_volume(workspace, scale_state)

        # Assert
        expected_volume = thickness * math.pi * math.pow(width, 2) / 4.0
        expected_value = 0.3 / expected_volume
        data_y = output_workspace.dataY(0)
        self.assertEqual(data_y[0], expected_value)
开发者ID:DanNixon,项目名称:mantid,代码行数:34,代码来源:scale_helper_test.py


示例4: test_that_correct_scale_strategy_is_selected_for_loq_2

    def test_that_correct_scale_strategy_is_selected_for_loq_2(self):
        # Arrange
        facility = SANSFacility.ISIS
        data_builder = get_data_builder(facility)
        data_builder.set_sample_scatter("LOQ74044")
        data_state = data_builder.build()

        scale_builder = get_scale_builder(data_state)
        scale_builder.set_scale(2.4)
        scale_state = scale_builder.build()

        test_director = TestDirector()
        test_director.set_states(scale_state=scale_state, data_state=data_state)
        state_loq = test_director.construct()

        absolute_multiply_factory = MultiplyByAbsoluteScaleFactory()
        multiplier = absolute_multiply_factory.create_multiply_by_absolute(state_loq)

        workspace = self._get_workspace()

        # Act
        output_workspace = multiplier.multiply_by_absolute_scale(workspace, state_loq.scale)

        # Assert
        expected_value = 0.3 * 2.4 / math.pi * 100.
        data_y = output_workspace.dataY(0)
        self.assertEqual(data_y[0], expected_value)
开发者ID:DanNixon,项目名称:mantid,代码行数:27,代码来源:scale_helper_test.py


示例5: test_that_cylinder_masking_is_applied

    def test_that_cylinder_masking_is_applied(self):
        # Arrange
        data_builder = get_data_builder(SANSFacility.ISIS)
        data_builder.set_sample_scatter("SANS2D00028827")
        data_info = data_builder.build()
        mask_builder = get_mask_builder(data_info)

        # Radius Mask
        radius_min = 0.01
        radius_max = 10.

        expected_spectra = []
        expected_spectra.extend([30469, 30470, 30471, 30472, 30473, 30474, 30475, 30476, 30477, 30980,
                                 30981, 30982, 30983, 30984, 30985, 30986, 30987, 30988])
        mask_builder.set_radius_min(radius_min)
        mask_builder.set_radius_max(radius_max)

        mask_info = mask_builder.build()

        test_director = TestDirector()
        test_director.set_states(data_state=data_info, mask_state=mask_info)
        state = test_director.construct()

        workspace = self._load_workspace(state, move_workspace=False)

        # Act
        workspace = self._run_mask(state, workspace, "LAB")

        # Assert
        self._do_assert(workspace, expected_spectra)
开发者ID:DanNixon,项目名称:mantid,代码行数:30,代码来源:SANSMaskWorkspaceTest.py


示例6: test_that_beam_stop_masking_is_applied

    def test_that_beam_stop_masking_is_applied(self):
        # Arrange
        data_builder = get_data_builder(SANSFacility.ISIS)
        data_builder.set_sample_scatter("SANS2D00028827")
        data_info = data_builder.build()
        mask_builder = get_mask_builder(data_info)

        beam_stop_arm_width = .01
        beam_stop_arm_angle = 180.0
        beam_stop_arm_pos1 = 0.0
        beam_stop_arm_pos2 = 0.0

        # Expected_spectra, again the tubes are shifted and that will produce the slightly strange masking
        expected_spectra = []
        expected_spectra.extend((512*59 + 9 + x for x in range(0, 257)))
        expected_spectra.extend((512*60 + 9 + x for x in range(0, 255)))

        mask_builder.set_beam_stop_arm_width(beam_stop_arm_width)
        mask_builder.set_beam_stop_arm_angle(beam_stop_arm_angle)
        mask_builder.set_beam_stop_arm_pos1(beam_stop_arm_pos1)
        mask_builder.set_beam_stop_arm_pos2(beam_stop_arm_pos2)

        mask_info = mask_builder.build()

        test_director = TestDirector()
        test_director.set_states(data_state=data_info, mask_state=mask_info)
        state = test_director.construct()

        workspace = self._load_workspace(state, move_workspace=False)

        # Act
        workspace = self._run_mask(state, workspace, "LAB")

        # Assert
        self._do_assert(workspace, expected_spectra)
开发者ID:DanNixon,项目名称:mantid,代码行数:35,代码来源:SANSMaskWorkspaceTest.py


示例7: _get_state

    def _get_state(background_TOF_general_start=None, background_TOF_general_stop=None,
                   background_TOF_monitor_start=None, background_TOF_monitor_stop=None, incident_monitor=None,
                   prompt_peak_correction_min=None, prompt_peak_correction_max=None):
        test_director = TestDirector()
        state = test_director.construct()

        data_state = state.data
        normalize_to_monitor_builder = get_normalize_to_monitor_builder(data_state)
        normalize_to_monitor_builder.set_rebin_type(RebinType.Rebin)
        normalize_to_monitor_builder.set_wavelength_low(2.)
        normalize_to_monitor_builder.set_wavelength_high(8.)
        normalize_to_monitor_builder.set_wavelength_step(2.)
        normalize_to_monitor_builder.set_wavelength_step_type(RangeStepType.Lin)
        if background_TOF_general_start:
            normalize_to_monitor_builder.set_background_TOF_general_start(background_TOF_general_start)
        if background_TOF_general_stop:
            normalize_to_monitor_builder.set_background_TOF_general_stop(background_TOF_general_stop)
        if background_TOF_monitor_start:
            normalize_to_monitor_builder.set_background_TOF_monitor_start(background_TOF_monitor_start)
        if background_TOF_monitor_stop:
            normalize_to_monitor_builder.set_background_TOF_monitor_stop(background_TOF_monitor_stop)
        if incident_monitor:
            normalize_to_monitor_builder.set_incident_monitor(incident_monitor)
        if prompt_peak_correction_min:
            normalize_to_monitor_builder.set_prompt_peak_correction_min(prompt_peak_correction_min)
        if prompt_peak_correction_max:
            normalize_to_monitor_builder.set_prompt_peak_correction_max(prompt_peak_correction_max)
        if prompt_peak_correction_min and prompt_peak_correction_max:
            normalize_to_monitor_builder.set_prompt_peak_correction_enabled(True)

        normalize_to_monitor_state = normalize_to_monitor_builder.build()
        state.adjustment.normalize_to_monitor = normalize_to_monitor_state

        return state.property_manager
开发者ID:DanNixon,项目名称:mantid,代码行数:34,代码来源:SANSNormalizeToMonitorTest.py


示例8: _get_sample_state

    def _get_sample_state(q_min=1., q_max=2., q_step=0.1, q_step_type=RangeStepType.Lin,
                          q_xy_max=None, q_xy_step=None, q_xy_step_type=None,
                          use_gravity=False, dim=ReductionDimensionality.OneDim):
        # Arrange
        facility = SANSFacility.ISIS
        data_builder = get_data_builder(facility)
        data_builder.set_sample_scatter("LOQ74044")
        data_state = data_builder.build()

        convert_to_q_builder = get_convert_to_q_builder(data_state)
        convert_to_q_builder.set_reduction_dimensionality(dim)
        convert_to_q_builder.set_use_gravity(use_gravity)
        convert_to_q_builder.set_radius_cutoff(0.002)
        convert_to_q_builder.set_wavelength_cutoff(2.)
        convert_to_q_builder.set_q_min(q_min)
        convert_to_q_builder.set_q_max(q_max)
        prefix = 1. if q_step_type is RangeStepType.Lin else -1.
        q_step *= prefix
        rebin_string = str(q_min) + "," + str(q_step) + "," + str(q_max)
        convert_to_q_builder.set_q_1d_rebin_string(rebin_string)
        if q_xy_max is not None:
            convert_to_q_builder.set_q_xy_max(q_xy_max)
        if q_xy_step is not None:
            convert_to_q_builder.set_q_xy_step(q_xy_step)
        if q_xy_step_type is not None:
            convert_to_q_builder.set_q_xy_step_type(q_xy_step_type)

        convert_to_q_state = convert_to_q_builder.build()

        test_director = TestDirector()
        test_director.set_states(convert_to_q_state=convert_to_q_state, data_state=data_state)

        return test_director.construct().property_manager
开发者ID:DanNixon,项目名称:mantid,代码行数:33,代码来源:SANSConvertToQTest.py


示例9: _get_state

 def _get_state(lab_pixel_file=None, hab_pixel_file=None, lab_wavelength_file=None, hab_wavelength_file=None,
                wavelength_low=None, wavelength_high=None, wavelength_step=None,
                wavelength_step_type=None):
     test_director = TestDirector()
     state = test_director.construct()
     data_state = state.data
     wavelength_and_pixel_builder = get_wavelength_and_pixel_adjustment_builder(data_state)
     if lab_pixel_file:
         wavelength_and_pixel_builder.set_LAB_pixel_adjustment_file(lab_pixel_file)
     if hab_pixel_file:
         wavelength_and_pixel_builder.set_HAB_pixel_adjustment_file(hab_pixel_file)
     if lab_wavelength_file:
         wavelength_and_pixel_builder.set_LAB_wavelength_adjustment_file(lab_wavelength_file)
     if hab_wavelength_file:
         wavelength_and_pixel_builder.set_HAB_wavelength_adjustment_file(hab_wavelength_file)
     if wavelength_step_type:
         wavelength_and_pixel_builder.set_wavelength_step_type(wavelength_step_type)
     if wavelength_low:
         wavelength_and_pixel_builder.set_wavelength_low(wavelength_low)
     if wavelength_high:
         wavelength_and_pixel_builder.set_wavelength_high(wavelength_high)
     if wavelength_step:
         wavelength_and_pixel_builder.set_wavelength_step(wavelength_step)
     wavelength_and_pixel_state = wavelength_and_pixel_builder.build()
     state.adjustment.wavelength_and_pixel_adjustment = wavelength_and_pixel_state
     return state.property_manager
开发者ID:DanNixon,项目名称:mantid,代码行数:26,代码来源:SANSCreateWavelengthAndPixelAdjustmentTest.py


示例10: test_that_can_find_can_reduction_if_it_exists

    def test_that_can_find_can_reduction_if_it_exists(self):
        # Arrange
        test_director = TestDirector()
        state = test_director.construct()
        tagged_workspace_names = {None: "test_ws",
                                  OutputParts.Count: "test_ws_count",
                                  OutputParts.Norm: "test_ws_norm"}
        SANSFunctionsTest._prepare_workspaces(number_of_workspaces=4,
                                              tagged_workspace_names=tagged_workspace_names,
                                              state=state,
                                              reduction_mode=ISISReductionMode.LAB)
        # Act
        workspace, workspace_count, workspace_norm = get_reduced_can_workspace_from_ads(state, output_parts=True,
                                                                              reduction_mode=ISISReductionMode.LAB)  # noqa

        # Assert
        self.assertTrue(workspace is not None)
        self.assertTrue(workspace.name() == AnalysisDataService.retrieve("test_ws").name())
        self.assertTrue(workspace_count is not None)
        self.assertTrue(workspace_count.name() == AnalysisDataService.retrieve("test_ws_count").name())
        self.assertTrue(workspace_norm is not None)
        self.assertTrue(workspace_norm.name() == AnalysisDataService.retrieve("test_ws_norm").name())

        # Clean up
        SANSFunctionsTest._remove_workspaces()
开发者ID:mantidproject,项目名称:mantid,代码行数:25,代码来源:general_functions_test.py


示例11: test_that_divide_strategy_is_selected_for_isis_instrument_and_is_not_can

 def test_that_divide_strategy_is_selected_for_isis_instrument_and_is_not_can(self):
     # Arrange
     test_director = TestDirector()
     state_isis = test_director.construct()
     divide_factory = DivideByVolumeFactory()
     # Act
     divider = divide_factory.create_divide_by_volume(state_isis)
     # Arrange
     self.assertTrue(isinstance(divider, DivideByVolumeISIS))
开发者ID:DanNixon,项目名称:mantid,代码行数:9,代码来源:scale_helper_test.py


示例12: test_that_correct_scale_strategy_is_selected_for_non_loq_isis_instrument

 def test_that_correct_scale_strategy_is_selected_for_non_loq_isis_instrument(self):
     # Arrange
     test_director = TestDirector()
     state_isis = test_director.construct()
     absolute_multiply_factory = MultiplyByAbsoluteScaleFactory()
     # Act
     multiplier = absolute_multiply_factory.create_multiply_by_absolute(state_isis)
     # Arrange
     self.assertTrue(isinstance(multiplier, MultiplyByAbsoluteScaleISIS))
开发者ID:DanNixon,项目名称:mantid,代码行数:9,代码来源:scale_helper_test.py


示例13: _get_simple_state

    def _get_simple_state(sample_scatter, sample_trans=None, sample_direct=None,
                          can_scatter=None, can_trans=None, can_direct=None, calibration=None,
                          sample_scatter_period=None, sample_trans_period=None, sample_direct_period=None,
                          can_scatter_period=None, can_trans_period=None, can_direct_period=None):
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information(sample_scatter)

        data_builder = get_data_builder(SANSFacility.ISIS, file_information)
        data_builder.set_sample_scatter(sample_scatter)

        # Set the file names
        if sample_trans is not None:
            data_builder.set_sample_transmission(sample_trans)

        if sample_direct is not None:
            data_builder.set_sample_direct(sample_direct)

        if can_scatter is not None:
            data_builder.set_can_scatter(can_scatter)

        if can_trans is not None:
            data_builder.set_can_transmission(can_trans)

        if can_direct is not None:
            data_builder.set_can_direct(can_direct)

        # Set the periods
        if sample_scatter_period is not None:
            data_builder.set_sample_scatter_period(sample_scatter_period)

        if sample_trans_period is not None:
            data_builder.set_sample_transmission_period(sample_trans_period)

        if sample_direct_period is not None:
            data_builder.set_sample_direct_period(sample_direct_period)

        if can_scatter_period is not None:
            data_builder.set_can_scatter_period(can_scatter_period)

        if can_trans_period is not None:
            data_builder.set_can_transmission_period(can_trans_period)

        if can_direct_period is not None:
            data_builder.set_can_direct_period(can_direct_period)

        # Add the calibration
        if calibration is not None:
            data_builder.set_calibration(calibration)

        data_info = data_builder.build()

        # Get the sample state
        test_director = TestDirector()
        test_director.set_states(data_state=data_info)

        return test_director.construct()
开发者ID:samueljackson92,项目名称:mantid,代码行数:56,代码来源:SANSLoadTest.py


示例14: get_example_state

def get_example_state():
    ws_name_sample = "SANS2D00022024"
    data_builder = get_data_builder(SANSFacility.ISIS)
    data_builder.set_sample_scatter(ws_name_sample)
    data = data_builder.build()

    # Get the sample state
    test_director = TestDirector()
    test_director.set_states(data_state=data)
    return test_director.construct()
开发者ID:DanNixon,项目名称:mantid,代码行数:10,代码来源:property_manager_service_test.py


示例15: get_example_state

def get_example_state():
    ws_name_sample = "SANS2D00022024"
    file_information = SANSFileInformationMock(instrument=SANSInstrument.SANS2D, run_number=22024)
    data_builder = get_data_builder(SANSFacility.ISIS, file_information)
    data_builder.set_sample_scatter(ws_name_sample)
    data = data_builder.build()

    # Get the sample state
    test_director = TestDirector()
    test_director.set_states(data_state=data)
    return test_director.construct()
开发者ID:mantidproject,项目名称:mantid,代码行数:11,代码来源:property_manager_service_test.py


示例16: _get_simple_state

    def _get_simple_state(fit_type=FitModeForMerge.NoFit, scale=1.0, shift=0.0):
        # Set the reduction parameters
        reduction_info = StateReductionMode()
        reduction_info.reduction_mode = ISISReductionMode.Merged
        reduction_info.dimensionality = ReductionDimensionality.TwoDim
        reduction_info.merge_shift = shift
        reduction_info.merge_scale = scale
        reduction_info.merge_fit_mode = fit_type

        # Get the sample state
        test_director = TestDirector()
        test_director.set_states(reduction_state=reduction_info)
        return test_director.construct()
开发者ID:DanNixon,项目名称:mantid,代码行数:13,代码来源:merge_reductions_test.py


示例17: _get_state

    def _get_state(start_time=None, end_time=None):
        test_director = TestDirector()
        state = test_director.construct()

        # Create the slice range if required
        if start_time is not None and end_time is not None:
            data_state = state.data
            slice_builder = get_slice_event_builder(data_state)
            slice_builder.set_start_time(start_time)
            slice_builder.set_end_time(end_time)
            slice_state = slice_builder.build()
            state.slice = slice_state
        return state.property_manager
开发者ID:mantidproject,项目名称:mantid,代码行数:13,代码来源:SANSSliceEventTest.py


示例18: test_that_angle_masking_is_applied

    def test_that_angle_masking_is_applied(self):
        # Arrange
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information("SANS2D00028827")
        data_builder = get_data_builder(SANSFacility.ISIS, file_information)
        data_builder.set_sample_scatter("SANS2D00028827")
        data_info = data_builder.build()

        mask_builder = get_mask_builder(data_info)

        # Expected_spectra
        phi_mirror = False
        phi_min = 0.
        phi_max = 90.
        # This should mask everything except for the upper right quadrant
        # | 120              |-------------------|
        # |                 |---------------------|
        # | 60               |-------------------|
        # |                 |----------------------|
        # |
        # |
        # |-------------------|------------------|
        # 512                256                 0

        expected_spectra = []
        # The strange double pattern arises from the offset of the SANS2D tube geometry (see InstrumentView)
        for y in range(60, 120):
            if y % 2 == 0:
                expected_spectra.extend(((y * 512) + 9 + x for x in range(0, 255)))
            else:
                expected_spectra.extend(((y * 512) + 9 + x for x in range(0, 257)))
        expected_spectra.extend((x for x in range(92169, 122889)))  # HAB

        mask_builder.set_use_mask_phi_mirror(phi_mirror)
        mask_builder.set_phi_min(phi_min)
        mask_builder.set_phi_max(phi_max)

        mask_info = mask_builder.build()

        test_director = TestDirector()
        test_director.set_states(data_state=data_info, mask_state=mask_info)
        state = test_director.construct()

        workspace = self._load_workspace(state)

        # Act
        workspace = self._run_mask(state, workspace, "LAB")

        # Assert
        self._do_assert_non_masked(workspace, expected_spectra)
开发者ID:mantidproject,项目名称:mantid,代码行数:50,代码来源:SANSMaskWorkspaceTest.py


示例19: test_that_mask_files_are_applied

    def test_that_mask_files_are_applied(self):
        def create_shape_xml_file(xml_string):
            f_name = os.path.join(mantid.config.getString('defaultsave.directory'), 'sample_mask_file.xml')
            if os.path.exists(f_name):
                os.remove(f_name)
            with open(f_name, 'w') as f:
                f.write(xml_string)
            return f_name

        # Arrange
        shape_xml = "<?xml version=\"1.0\"?>\n"\
                    "<detector-masking>\n" \
                    "<group>\n" \
                    "<detids>\n" \
                    "1313191-1313256\n" \
                    "</detids>\n" \
                    "</group>\n" \
                    "</detector-masking >"
        file_name = create_shape_xml_file(shape_xml)

        # Arrange
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information("SANS2D00028827")
        data_builder = get_data_builder(SANSFacility.ISIS, file_information)
        data_builder.set_sample_scatter("SANS2D00028827")
        data_info = data_builder.build()
        mask_builder = get_mask_builder(data_info)

        # Mask file
        # Got the spectra from the detector view
        expected_spectra = [x for x in range(31432, 31498)]
        mask_builder.set_mask_files([file_name])
        mask_info = mask_builder.build()

        test_director = TestDirector()
        test_director.set_states(data_state=data_info, mask_state=mask_info)
        state = test_director.construct()

        workspace = self._load_workspace(state, move_workspace=False)

        # Act
        workspace = self._run_mask(state, workspace, "LAB")

        # Assert
        self._do_assert(workspace, expected_spectra)

        # Remove
        if os.path.exists(file_name):
            os.remove(file_name)
开发者ID:samueljackson92,项目名称:mantid,代码行数:49,代码来源:SANSMaskWorkspaceTest.py


示例20: test_that_general_time_masking_is_applied

    def test_that_general_time_masking_is_applied(self):
        # Arrange
        file_information_factory = SANSFileInformationFactory()
        file_information = file_information_factory.create_sans_file_information("SANS2D00028827")
        data_builder = get_data_builder(SANSFacility.ISIS, file_information)
        data_builder.set_sample_scatter("SANS2D00028827")
        data_info = data_builder.build()
        mask_builder = get_mask_builder(data_info)

        # Expected_spectra
        bin_mask_general_start = [30000., 67000.]
        bin_mask_general_stop = [35000., 75000.]

        # bin_mask_start = [14000]
        # bin_mask_stop = FloatListParameter()

        mask_builder.set_bin_mask_general_start(bin_mask_general_start)
        mask_builder.set_bin_mask_general_stop(bin_mask_general_stop)

        mask_info = mask_builder.build()

        test_director = TestDirector()
        test_director.set_states(data_state=data_info, mask_state=mask_info)
        state = test_director.construct()

        workspace = self._load_workspace(state, move_workspace=False)

        tof_spectra_10_original = workspace.getSpectrum(10).getTofs()
        tof_spectra_11_original = workspace.getSpectrum(11).getTofs()

        # Act
        workspace = self._run_mask(state, workspace, "LAB")

        # Assert
        # Confirm that everything in the ranges 30000-35000  and 67000-75000 is removed from the event list
        tof_spectra_10_masked = workspace.getSpectrum(10).getTofs()
        tof_spectra_11_masked = workspace.getSpectrum(11).getTofs()
        # Spectrum 10
        # Three events should have been removed
        self.assertTrue(len(tof_spectra_10_masked) == len(tof_spectra_10_original) - 3)
        # One event should have been removed
        self.assertTrue(len(tof_spectra_11_masked) == len(tof_spectra_11_original) - 1)

        # Make sure that there are no elements
        for start, stop in zip(bin_mask_general_start, bin_mask_general_stop):
            self.assertFalse(any(elements_in_range(start, stop, tof_spectra_10_masked)))
            self.assertFalse(any(elements_in_range(start, stop, tof_spectra_11_masked)))
开发者ID:samueljackson92,项目名称:mantid,代码行数:47,代码来源:SANSMaskWorkspaceTest.py



注:本文中的sans.test_helper.test_director.TestDirector类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python model.DBSession类代码示例发布时间:2022-05-27
下一篇:
Python data.get_data_builder函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap