def test_that_a_reduction_performed_with_a_spectra_range_will_result_in_a_workspace_with_a_correct_number_of_histograms(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[35, 40])

        red_workspace = workspace.getItem(0)
        self.assertEqual(red_workspace.getNumberHistograms(), 6)
    def test_that_a_basic_reduction_will_produce_a_workspace_with_the_correct_number_of_histograms(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[3, 53])

        red_workspace = workspace.getItem(0)
        self.assertEqual(red_workspace.getNumberHistograms(), 51)
    def test_that_a_basic_reduction_will_produce_a_workspace_with_the_correct_number_of_histograms(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[3, 53])

        red_workspace = workspace.getItem(0)
        self.assertEqual(red_workspace.getNumberHistograms(), 51)
    def test_that_a_basic_reduction_will_produce_a_workspace_with_the_correct_x_axis_units(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[3, 53])

        red_workspace = workspace.getItem(0)
        self.assertEqual(red_workspace.getAxis(0).getUnit().unitID(), 'DeltaE')
    def test_that_a_basic_reduction_will_produce_a_workspace_with_the_correct_x_axis_units(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[3, 53])

        red_workspace = workspace.getItem(0)
        self.assertEqual(red_workspace.getAxis(0).getUnit().unitID(), 'DeltaE')
    def test_that_a_reduction_performed_with_a_spectra_range_will_result_in_a_workspace_with_a_correct_number_of_histograms(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[35, 40])

        red_workspace = workspace.getItem(0)
        self.assertEqual(red_workspace.getNumberHistograms(), 6)
    def test_that_a_reduction_which_is_given_an_output_unit_will_produce_a_workspace_with_the_correct_units(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[3, 53],
                                                      UnitX='DeltaE_inWavenumber')

        red_workspace = workspace.getItem(0)
        self.assertEqual(red_workspace.getNumberHistograms(), 51)
        self.assertEqual(red_workspace.getAxis(0).getUnit().unitID(), 'DeltaE_inWavenumber')
    def test_that_a_reduction_which_is_given_an_output_unit_will_produce_a_workspace_with_the_correct_units(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[3, 53],
                                                      UnitX='DeltaE_inWavenumber')

        red_workspace = workspace.getItem(0)
        self.assertEqual(red_workspace.getNumberHistograms(), 51)
        self.assertEqual(red_workspace.getAxis(0).getUnit().unitID(), 'DeltaE_inWavenumber')
    def test_that_the_history_contains_only_one_parent_algorithm_which_has_the_correct_name(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[3, 53])

        history = workspace.getItem(0).getHistory()
        algorithm_names = [alg.name() for alg in history]

        self.assertEqual(len(algorithm_names), 1)
        self.assertEqual(algorithm_names[0], 'ISISIndirectEnergyTransferWrapper')
    def test_that_the_history_contains_only_one_parent_algorithm_which_has_the_correct_name(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[3, 53])

        history = workspace.getItem(0).getHistory()
        algorithm_names = [alg.name() for alg in history]

        self.assertEqual(len(algorithm_names), 1)
        self.assertEqual(algorithm_names[0], 'ISISIndirectEnergyTransferWrapper')
    def test_that_a_reduction_with_a_calibration_workspace_and_range_will_produce_a_workspace_with_the_correct_number_of_histograms(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[35, 40],
                                                      CalibrationWorkspace=_generate_calibration_workspace('IRIS'))

        self.assertTrue(isinstance(workspace, WorkspaceGroup), 'Result workspace should be a workspace group.')
        self.assertEqual(workspace.getNames()[0], 'iris26176_graphite002_red')

        red_workspace = workspace.getItem(0)
        self.assertEqual(red_workspace.getNumberHistograms(), 6)
    def test_that_the_history_of_ISISIndirectEnergyTransferWrapper_has_no_child_algorithms(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[3, 53])

        history = workspace.getItem(0).getHistory()

        child_histories = history.getAlgorithmHistory(0).getChildHistories()
        algorithm_names = [alg.name() for alg in child_histories]

        self.assertFalse(algorithm_names)
    def test_that_a_reduction_with_a_manual_efixed_will_return_a_workspace_with_the_correct_naming_and_number_of_histograms(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[3, 53],
                                                      Efixed=1.9)

        self.assertTrue(isinstance(workspace, WorkspaceGroup), 'Result workspace should be a workspace group.')
        self.assertEqual(workspace.getNames()[0], 'iris26176_graphite002_red')

        red_workspace = workspace.getItem(0)
        self.assertEqual(red_workspace.getNumberHistograms(), 51)
    def test_that_a_reduction_with_a_manual_efixed_will_return_a_workspace_with_the_correct_naming_and_number_of_histograms(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[3, 53],
                                                      Efixed=1.9)

        self.assertTrue(isinstance(workspace, WorkspaceGroup), 'Result workspace should be a workspace group.')
        self.assertEqual(workspace.getNames()[0], 'iris26176_graphite002_red')

        red_workspace = workspace.getItem(0)
        self.assertEqual(red_workspace.getNumberHistograms(), 51)
    def test_that_a_reduction_with_a_calibration_workspace_and_range_will_produce_a_workspace_with_the_correct_number_of_histograms(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[35, 40],
                                                      CalibrationWorkspace=_generate_calibration_workspace('IRIS'))

        self.assertTrue(isinstance(workspace, WorkspaceGroup), 'Result workspace should be a workspace group.')
        self.assertEqual(workspace.getNames()[0], 'iris26176_graphite002_red')

        red_workspace = workspace.getItem(0)
        self.assertEqual(red_workspace.getNumberHistograms(), 6)
    def test_that_the_history_of_ISISIndirectEnergyTransferWrapper_has_no_child_algorithms(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['IRS26176.RAW'],
                                                      Instrument='IRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[3, 53])

        history = workspace.getItem(0).getHistory()

        child_histories = history.getAlgorithmHistory(0).getChildHistories()
        algorithm_names = [alg.name() for alg in child_histories]

        self.assertFalse(algorithm_names)
    def test_that_a_reduction_using_a_map_file_will_produce_a_workspace_with_the_correct_number_of_histograms(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['OSI97919.raw'],
                                                      Instrument='OSIRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[963, 1004],
                                                      GroupingMethod='File',
                                                      MapFile='osi_002_14Groups.map')

        self.assertTrue(isinstance(workspace, WorkspaceGroup), 'Result workspace should be a workspace group.')
        self.assertEqual(workspace.getNames()[0], 'osiris97919_graphite002_red')

        red_workspace = workspace.getItem(0)
        self.assertEqual(red_workspace.getNumberHistograms(), 14)
    def test_that_a_reduction_using_a_map_file_will_produce_a_workspace_with_the_correct_number_of_histograms(self):
        workspace = ISISIndirectEnergyTransferWrapper(InputFiles=['OSI97919.raw'],
                                                      Instrument='OSIRIS',
                                                      Analyser='graphite',
                                                      Reflection='002',
                                                      SpectraRange=[963, 1004],
                                                      GroupingMethod='File',
                                                      MapFile='osi_002_14Groups.map')

        self.assertTrue(isinstance(workspace, WorkspaceGroup), 'Result workspace should be a workspace group.')
        self.assertEqual(workspace.getNames()[0], 'osiris97919_graphite002_red')

        red_workspace = workspace.getItem(0)
        self.assertEqual(red_workspace.getNumberHistograms(), 14)