当前位置: 首页>>代码示例>>Python>>正文


Python test_director.TestDirector类代码示例

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


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


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