def _create_data_workspace(data_ws_name, num_spec, tof0=None, delta=None, num_pts=None):
        """
        Create a multiple spectra data workspace
        :param data_ws_name:
        :param num_spec:
        :return:
        """
        # get base data sets for the workspace as Histograms
        tof0 = 10000.
        delta = 0.001
        num_pts = 200

        list_x = list()
        list_y = list()
        list_e = list()

        tof = tof0
        for n in range(num_pts):
            list_x.append(tof)
            list_y.append(math.sin(tof0))
            list_e.append(1.)

            tof *= 1+delta
        # END-FOR
        list_x.append(tof)

        vec_x = numpy.array(list_x)
        vec_y = numpy.array(list_y)
        vec_e = numpy.array(list_e)

        # expand to multiple spectra
        if num_spec > 1:
            vec_x_orig = vec_x[:]
            vec_y_orig = vec_y[:]
            vec_e_orig = vec_e[:]

            for spec_index in range(1, num_spec):
                vec_x = numpy.append(vec_x, vec_x_orig)
                vec_i = vec_y_orig[:]
                vec_i *= 2 * (spec_index + 1)
                vec_y = numpy.append(vec_y, vec_i)
                vec_e = numpy.append(vec_e, vec_e_orig)
        # END-FOR

        data_ws = api.CreateWorkspace(DataX=vec_x, DataY=vec_y, DataE=vec_e, NSpec=num_spec, UnitX="TOF")

        # Add to data service
        AnalysisDataService.addOrReplace(data_ws_name, data_ws)

        return data_ws
Esempio n. 2
0
    def test_call_inside_function_uses_new_variable_name(self):
        def rebin(workspace):
            # Should replace the input workspace
            workspace = simpleapi.Rebin(workspace, Params=[1, 0.1, 10])
            return workspace

        dataX = numpy.linspace(start=1, stop=3, num=11)
        dataY = numpy.linspace(start=1, stop=3, num=10)
        raw = simpleapi.CreateWorkspace(DataX=dataX, DataY=dataY, NSpec=1)
        raw = rebin(raw)
        # If this fails then the function above chose the name of the variable
        # over the actual object name
        self.assertTrue('workspace' in mtd)
        self.assertTrue('raw' in mtd)
Esempio n. 3
0
def prepare_wks_cost_function(prob, use_errors):
    """
    Build a workspace ready for Fit() and a cost function string according to the problem
    definition.
    """
    if use_errors:
        data_e = None
        if not isinstance(prob.data_pattern_obs_errors, np.ndarray):
            # Fake observational errors
            data_e = np.sqrt(prob.data_pattern_in)
        else:
            data_e = prob.data_pattern_obs_errors

        wks = msapi.CreateWorkspace(DataX=prob.data_pattern_in,
                                    DataY=prob.data_pattern_out,
                                    DataE=data_e)
        cost_function = 'Least squares'
    else:
        wks = msapi.CreateWorkspace(DataX=prob.data_pattern_in,
                                    DataY=prob.data_pattern_out)
        cost_function = 'Unweighted least squares'

    return wks, cost_function
 def _createOneHistogram(self, datawsname):
     """ Create data workspace
     """
     E = np.arange(-50.5, 50, 1.0)
     Ecenters = (E[:-1] + E[1:]) / 2
     I = 1000 * np.exp(-Ecenters**2/10**2)
     err = I ** .5
     # create workspace
     dataws = api.CreateWorkspace(
         DataX = E, DataY = I, DataE = err, NSpec = 1,
         UnitX = "Energy(meV)")
     # Add to data service
     AnalysisDataService.addOrReplace(datawsname, dataws)
     return E, I, err
Esempio n. 5
0
 def makeWs(self):
     simpleapi.CreateWorkspace(OutputWorkspace='test1',
                               DataX='1,2,3,4,5,1,2,3,4,5',
                               DataY='1,2,3,4,2,3,4,5',
                               DataE='1,2,3,4,2,3,4,5',
                               NSpec='2',
                               UnitX='dSpacing',
                               Distribution='1',
                               YUnitlabel="S(q)")
     simpleapi.CreateWorkspace(OutputWorkspace='test2',
                               DataX='1,2,3,4,5,1,2,3,4,5',
                               DataY='1,2,3,4,2,3,4,5',
                               DataE='1,2,3,4,2,3,4,5',
                               NSpec='2',
                               UnitX='Momentum',
                               VerticalAxisUnit='TOF',
                               VerticalAxisValues='1,2',
                               Distribution='1',
                               YUnitLabel='E',
                               WorkspaceTitle='x')
     simpleapi.GroupWorkspaces("test1,test2", OutputWorkspace="group")
     self.plotfile = os.path.join(config.getString('defaultsave.directory'),
                                  'plot.png')
Esempio n. 6
0
 def _createOneQCurve(self, datawsname):
     """ Create data workspace
     """
     Q = np.arange(0, 13, 1.0)
     dQ = 0.1*Q
     I = 1000 * np.exp(-Q**2/10**2)
     err = I ** .5
     # create workspace
     dataws = api.CreateWorkspace(
         DataX = Q, DataY = I, DataE = err, NSpec = 1,
         UnitX = "Momentum")
     dataws.setDx(0, dQ)
     # Add to data service
     AnalysisDataService.addOrReplace(datawsname, dataws)
     return Q, I, err, dQ
 def _createOneCurve(self, datawsname):
     """ Create data workspace
     """
     E = np.arange(-50, 50, 10.0)
     I = 1000 * np.exp(-E**2 / 10**2)
     err = I**.5
     # create workspace
     dataws = api.CreateWorkspace(DataX=E,
                                  DataY=I,
                                  DataE=err,
                                  NSpec=1,
                                  UnitX="Energy")
     # Add to data service
     AnalysisDataService.addOrReplace(datawsname, dataws)
     return E, I, err
Esempio n. 8
0
    def load_instrument(self):
        """
            Runs LoadInstrument get the parameters for the instrument
            @return the instrument parameter data
        """
        wrksp = '__' + self._NAME + 'instrument_definition'
        if not AnalysisDataService.doesExist(wrksp):
            api.CreateWorkspace(OutputWorkspace=wrksp,
                                DataX="1",
                                DataY="1",
                                DataE="1")
            #read the information about the instrument that stored in its xml
            api.LoadInstrument(Workspace=wrksp, InstrumentName=self._NAME)

        return AnalysisDataService.retrieve(wrksp).getInstrument()
Esempio n. 9
0
 def test_sample_ub(self):
     import mantid.simpleapi as mantid
     ws = mantid.CreateWorkspace(DataY=np.ones(1), DataX=np.arange(2))
     args = {'a': 1, 'b': 1, 'c': 1, 'alpha': 90, 'beta': 90, 'gamma': 90}
     mantid.SetUB(ws, **args)
     d = scn.mantid.from_mantid(ws)
     assert sc.identical(
         d.attrs['sample_ub'],
         sc.spatial.linear_transform(
             value=ws.sample().getOrientedLattice().getUB(),
             unit=sc.units.angstrom**-1))
     assert sc.identical(
         d.attrs['sample_u'],
         sc.spatial.linear_transform(
             value=ws.sample().getOrientedLattice().getU()))
    def test_ChildAlg_call_with_output_and_input_ws_the_same_succeeds(self):
        data = [1.0]
        api.CreateWorkspace(DataX=data,
                            DataY=data,
                            NSpec=1,
                            UnitX='Wavelength',
                            OutputWorkspace=self._ws_name)
        try:
            run_algorithm('PythonAlgorithmChildAlgCallTestAlg',
                          InputWorkspace=self._ws_name,
                          OutputWorkspace=self._ws_name)
        except Exception as exc:
            self.fail("Algorithm call failed: %s" % str(exc))

        self.assertTrue(self._ws_name in mtd)
        self.assertAlmostEqual(mtd[self._ws_name].readY(0)[0], 2.0, places=10)
Esempio n. 11
0
    def test_function_attached_as_workpace_method_does_the_same_as_the_free_function(self):
        # Use Rebin as a test
        ws1 = simpleapi.CreateWorkspace(DataX=[1.5,2.0,2.5,3.0],DataY=[1,2,3],NSpec=1,UnitX='Wavelength')
        self.assertTrue(hasattr(ws1, "rebin"))

        ws2 = simpleapi.Rebin(ws1,Params=[1.5,1.5,3])
        ws3 = ws1.rebin(Params=[1.5,1.5,3])
        ws4 = ws1.rebin([1.5,1.5,3])
        result = simpleapi.CompareWorkspaces(ws2,ws3)
        self.assertTrue(result[0])
        result = simpleapi.CompareWorkspaces(ws2,ws4)
        self.assertTrue(result[0])

        simpleapi.DeleteWorkspace(ws1)
        simpleapi.DeleteWorkspace(ws2)
        simpleapi.DeleteWorkspace(ws3)
def _prepare_workspace_for_stitching(cross_section, ws_name):
    """
        Create a workspace from a CrossSectionData object that we
        can call Stitch1D on.
        :param CrossSectionData cross_section: cross section data object
    """
    n_total = len(cross_section.q)
    p_0 = cross_section.configuration.cut_first_n_points
    p_n = n_total - cross_section.configuration.cut_last_n_points
    ws = api.CreateWorkspace(DataX=cross_section.q[p_0:p_n],
                             DataY=cross_section._r[p_0:p_n],
                             DataE=cross_section._dr[p_0:p_n],
                             OutputWorkspace=ws_name)
    ws.setDistribution(True)
    ws = api.ConvertToHistogram(ws, OutputWorkspace=ws_name)
    return ws
Esempio n. 13
0
    def test_run_normalise_by_current(self):
        initial_value = 17
        prtn_charge = '10.0'
        expected_value = initial_value / float(prtn_charge)

        # Create two workspaces
        ws = mantid.CreateWorkspace(DataX=0, DataY=initial_value)

        # Add Good Proton Charge Log
        mantid.AddSampleLog(Workspace=ws,
                            LogName='gd_prtn_chrg',
                            LogText=prtn_charge,
                            LogType='Number')

        self.assertEqual(initial_value, ws.dataY(0)[0])
        common.run_normalise_by_current(ws)
        self.assertAlmostEqual(expected_value, ws.dataY(0)[0], delta=1e-8)
Esempio n. 14
0
    def C2Se(self, sname):
        outWS = sname + '_Result'
        asc = self._read_ascii_file(sname + '.qse')
        var = asc[3].split()  # split line on spaces
        nspec = var[0]
        var = ExtractInt(asc[6])
        first = 7
        Xout = []
        Yf, Yi, Yb = [], [], []
        Ef, Ei, Eb = [], [], []
        ns = int(nspec)

        dataX = np.array([])
        dataY = np.array([])
        dataE = np.array([])
        data = np.array([dataX, dataY, dataE])

        for _ in range(0, ns):
            first, Q, _, fw, it, be = self.SeBlock(asc, first)
            Xout.append(Q)
            Yf.append(fw[0])
            Ef.append(fw[1])
            Yi.append(it[0])
            Ei.append(it[1])
            Yb.append(be[0])
            Eb.append(be[1])
        Vaxis = []

        dataX, dataY, dataE, data = self._add_xye_data(data, Xout, Yi, Ei)
        nhist = 1
        Vaxis.append('f1.Amplitude')

        dataX, dataY, dataE, data = self._add_xye_data(data, Xout, Yf, Ef)
        nhist += 1
        Vaxis.append('f1.FWHM')

        dataX, dataY, dataE, data = self._add_xye_data(data, Xout, Yb, Eb)
        nhist += 1
        Vaxis.append('f1.Beta')

        logger.information('Vaxis=' + str(Vaxis))
        s_api.CreateWorkspace(OutputWorkspace=outWS, DataX=dataX, DataY=dataY, DataE=dataE, Nspec=nhist,
                              UnitX='MomentumTransfer', VerticalAxisUnit='Text', VerticalAxisValues=Vaxis,
                              YUnitLabel='')

        return outWS
Esempio n. 15
0
def create_fake_dns_workspace(wsname,
                              angle=-7.53,
                              flipper='ON',
                              dataY=None,
                              loadinstrument=False):
    """
    creates DNS workspace with fake data
        @param angle   Angle of detector bank rotation
        @param flipper Flipper state (ON/OFF)
        @param dataY   Data array to set as DataY of the created workspace, will be set to np.ones if None
        @param loadinstrument  If True api.LoadInstrument will be executed, needed for DNSMergeRuns
    """
    ndet = 24
    dataX = np.zeros(2 * ndet)
    dataX.fill(4.2 + 0.00001)
    dataX[::2] -= 0.000002
    if dataY is None:
        dataY = np.ones(ndet)
    dataE = np.sqrt(dataY)
    # create workspace
    api.CreateWorkspace(OutputWorkspace=wsname,
                        DataX=dataX,
                        DataY=dataY,
                        DataE=dataE,
                        NSpec=ndet,
                        UnitX="Wavelength")
    outws = api.mtd[wsname]
    p_names = 'deterota,wavelength,slit_i_left_blade_position,slit_i_right_blade_position,normalized,\
            slit_i_lower_blade_position,slit_i_upper_blade_position,polarisation,polarisation_comment,flipper'

    p_values = str(angle) + ',4.2,10,10,duration,5,20,x,7a,' + flipper
    api.AddSampleLogMultiple(Workspace=outws,
                             LogNames=p_names,
                             LogValues=p_values,
                             ParseType=True)
    # rotate instrument component
    if loadinstrument:
        api.LoadInstrument(outws, InstrumentName='DNS', RewriteSpectraMap=True)
        api.RotateInstrumentComponent(outws,
                                      "bank0",
                                      X=0,
                                      Y=1,
                                      Z=0,
                                      Angle=angle)

    return outws
Esempio n. 16
0
    def _rebinVdrive(self, inputws, vec_refT, outputwsname):
        """ Rebin to match VULCAN's VDRIVE-generated GSAS file
        Arguments:
         - inputws : focussed workspace
         - vec_refT: list of TOF bins
        """
        # Create a complicated bin parameter
        params = []
        for ibin in xrange(len(vec_refT) - 1):
            x0 = vec_refT[ibin]
            xf = vec_refT[ibin + 1]
            dx = xf - x0
            params.append(x0)
            params.append(dx)

        # last bin
        x0 = vec_refT[-1]
        xf = 2 * dx + x0
        params.extend([x0, 2 * dx, xf])

        # Rebin
        tempws = api.Rebin(InputWorkspace=inputws,
                           Params=params,
                           PreserveEvents=False)

        # Map to a new workspace with 'vdrive-bin', which is the integer value of log bins
        numhist = tempws.getNumberHistograms()
        newvecx = []
        newvecy = []
        newvece = []
        for iws in xrange(numhist):
            vecx = tempws.readX(iws)
            vecy = tempws.readY(iws)
            vece = tempws.readE(iws)
            for i in xrange(len(vecx) - 1):
                newvecx.append(int(vecx[i] * 10) / 10.)
                newvecy.append(vecy[i])
                newvece.append(vece[i])
            # ENDFOR (i)
        # ENDFOR (iws)
        api.DeleteWorkspace(Workspace=tempws)
        gsaws = api.CreateWorkspace(DataX=newvecx, DataY=newvecy, DataE=newvece, NSpec=numhist,\
                UnitX="TOF", ParentWorkspace=inputws, OutputWorkspace=outputwsname)

        return gsaws
Esempio n. 17
0
    def test_function_call_raises_ValueError_when_not_enough_arguments_in_return_tuple(self):
        dataX=numpy.linspace(start=1,stop=3,num=11)
        dataY=numpy.linspace(start=1,stop=3,num=10)
        workspace1_test = simpleapi.CreateWorkspace(DataX=dataX, dataY=dataY, NSpec=1)
        workspace2_test = simpleapi.CloneWorkspace(workspace1_test)

        ws1_name = "workspace1_test"
        ws2_name = "workspace2_test"

        self.assertTrue(ws1_name in mtd)
        self.assertTrue(ws2_name in mtd)

        try:
            (result, ) = simpleapi.CompareWorkspaces(workspace1_test, workspace2_test)
            self.fail("Should not have made it to this point.")
        except(ValueError):
            pass

        simpleapi.DeleteWorkspace(ws1_name)
        simpleapi.DeleteWorkspace(ws2_name)
Esempio n. 18
0
def test_time_series_log_extraction():
    import mantid.simpleapi as sapi
    ws = sapi.CreateWorkspace(DataX=[0, 1], DataY=[1])
    times = [
        np.datetime64(t) for t in
        ['2021-01-01T00:00:00', '2021-01-01T00:30:00', '2021-01-01T00:50:00']
    ]
    for i, t in enumerate(times):
        sapi.AddTimeSeriesLog(ws, Name='time_log', Time=str(t), Value=float(i))
    da = scn.from_mantid(ws)
    assert da.attrs['time_log'].value.coords[
        'time'].dtype == sc.DType.datetime64
    # check times
    assert sc.identical(
        sc.Variable(dims=['time'],
                    values=np.array(times).astype('datetime64[ns]')),
        da.attrs['time_log'].value.coords['time'])
    # check values
    assert sc.identical(sc.Variable(dims=['time'], values=np.arange(3.)),
                        da.attrs['time_log'].value.data)
    sapi.DeleteWorkspace(ws)
Esempio n. 19
0
    def prepare_plot_data(self):
        """
            Bin events to be used for plotting and in-app calculations
        """
        workspace = api.mtd[self._event_workspace]
        if self.xtofdata is None:
            t_0 = time.time()
            binning_ws = api.CreateWorkspace(
                DataX=self.tof_edges, DataY=np.zeros(len(self.tof_edges) - 1))
            data_rebinned = api.RebinToWorkspace(WorkspaceToRebin=workspace,
                                                 WorkspaceToMatch=binning_ws)
            Ixyt = getIxyt(data_rebinned)

            # Create projections for the 2D datasets
            Ixy = Ixyt.sum(axis=2)
            Ixt = Ixyt.sum(axis=1)
            # Store the data
            self.data = Ixyt.astype(float)  # 3D dataset
            self.xydata = Ixy.transpose().astype(float)  # 2D dataset
            self.xtofdata = Ixt.astype(float)  # 2D dataset
            logging.info("Plot data generated: %s sec", time.time() - t_0)
Esempio n. 20
0
def build_visual_display_page(prob_results, group_name):
    """
    Builds a page containing details of the best fit for a problem.
    @param prob_results:: the list of results for a problem
    @param group_name :: the name of the group, e.g. "nist_lower"
    """
    # Get the best result for a group
    gb = min((result for result in prob_results), key=lambda result: result.fit_chi2)
    file_name = (group_name + '_' + gb.problem.name).lower()
    wks = msapi.CreateWorkspace(OutputWorkspace=gb.problem.name, DataX=gb.problem.data_pattern_in, DataY=gb.problem.data_pattern_out)
    qti.plot(wks, 0)
    # Create various page headings, ensuring the adornment is (at least) the length of the title
    title = '=' * len(gb.problem.name) + '\n'
    title += gb.problem.name + '\n'
    title += '=' * len(gb.problem.name) + '\n\n'
    data_plot = 'Plot of the data' + '\n'
    data_plot += ('-' * len(data_plot)) + '\n\n'
    data_plot += '.. image:: ' + file_name + '.png' + '\n\n'
    starting_plot = 'Plot of the initial starting guess' + '\n'
    starting_plot += ('-' * len(starting_plot)) + '\n\n'
    starting_plot += '.. figure:: ' + '\n\n'
    solution_plot = 'Plot of the solution found' + '\n'
    solution_plot += ('-' * len(solution_plot)) + '\n\n'
    solution_plot += '.. figure:: ' + '\n\n'
    problem = 'Fit problem' + '\n'
    problem += ('-' * len(problem)) + '\n'
    rst_text = title + data_plot + starting_plot + solution_plot + problem

    html = publish_string(rst_text, writer_name='html')
    with open(file_name + '.' + FILENAME_EXT_TXT, 'w') as visual_rst:
        print(html, file=visual_rst)
        print('Saved {file_name}.{extension} to {working_directory}'.
              format(file_name=file_name, extension=FILENAME_EXT_TXT, working_directory=WORKING_DIR))
    with open(file_name + '.' + FILENAME_EXT_HTML, 'w') as visual_html:
        print(html, file=visual_html)
        print('Saved {file_name}.{extension} to {working_directory}'.
              format(file_name=file_name, extension=FILENAME_EXT_HTML, working_directory=WORKING_DIR))

    rst_link = '`<' + file_name + '.' + FILENAME_EXT_HTML + '>`_'  # `<cutest_palmer6c.dat.html>`_
    return rst_link
Esempio n. 21
0
    def __init__(self, problem):
        """
        Setup workspace, cost_function, ignore_invalid, and initialise vars
        used for temporary storage within the mantid controller

        :param problem: Problem to fit
        :type problem: FittingProblem
        """
        super(MantidController, self).__init__(problem)

        self._param_names = self.problem.param_names

        self._cost_function = 'Least squares' if self.data_e is not None \
            else 'Unweighted least squares'

        data_obj = msapi.CreateWorkspace(DataX=self.data_x,
                                         DataY=self.data_y,
                                         DataE=self.data_e)

        self._mantid_data = data_obj
        self._mantid_function = None
        self._mantid_results = None
Esempio n. 22
0
    def _create_workspace(self,
                          name,
                          xye,
                          num_spec,
                          vert_axis,
                          is_zp_ws=False):
        """
        Creates a workspace from FORTRAN data

        @param name         :: Full name of outputworkspace
        @param xye          :: List of axis data [x, y , e]
        @param num_spec     :: Number of spectra
        @param vert_axis    :: The values on the vertical axis
        @param is_zp_ws     :: Creating a zp_ws (if True)
        """

        unit_x = ''
        if is_zp_ws:
            unit_x = 'MomentumTransfer'

        ws = s_api.CreateWorkspace(OutputWorkspace=name,
                                   DataX=xye[0],
                                   DataY=xye[1],
                                   DataE=xye[2],
                                   Nspec=num_spec,
                                   UnitX=unit_x,
                                   VerticalAxisUnit='MomentumTransfer',
                                   VerticalAxisValues=vert_axis)

        unitx = ws.getAxis(0).setUnit("Label")
        if is_zp_ws:
            unity = ws.getAxis(1).setUnit("Label")
            unitx.setLabel('beta', '')
            unity.setLabel('sigma', '')
        else:
            if name[-4:] == 'Beta':
                unitx.setLabel('beta', '')
            else:
                unitx.setLabel('sigma', '')
Esempio n. 23
0
def analisePeakTable(pTable, peaksName='Peaks'):
    print('parsing the peak table')
    n = len(pTable)
    peaks = pTable.columnCount() - 1
    peaksId = n * ['']
    data = numpy.zeros((n, peaks))
    line = 0
    for row in pTable:
        data_row = [row['Peak%d' % (i)] for i in range(1, peaks + 1)]
        data[line, :] = data_row
        peaksId[line] = row['TubeId']
        line += 1
    # data now has all the peaks positions for each tube
    # the mean value is the expected value for the peak position for each tube
    expected_peak_pos = numpy.mean(data, axis=0)
    print(expected_peak_pos)
    # calculate how far from the expected position each peak position is
    distance_from_expected = numpy.abs(data - expected_peak_pos)

    mantid.CreateWorkspace(list(range(n)), distance_from_expected, NSpec=peaks, OutputWorkspace=peaksName)
    check = numpy.where(distance_from_expected > 10)[0]
    problematic_tubes = list(set(check))
    print('Tubes whose distance is far from the expected value: ', problematic_tubes)
Esempio n. 24
0
    def test_function_call_returns_tuple_when_a_single_argument_is_provided(self):
        dataX=numpy.linspace(start=1,stop=3,num=11)
        dataY=numpy.linspace(start=1,stop=3,num=10)
        workspace1_test = simpleapi.CreateWorkspace(DataX=dataX, dataY=dataY, NSpec=1)
        workspace2_test = simpleapi.CloneWorkspace(workspace1_test)

        ws1_name = "workspace1_test"
        ws2_name = "workspace2_test"

        self.assertTrue(ws1_name in mtd)
        self.assertTrue(ws2_name in mtd)

        outputWs_name = "message"

        if outputWs_name in mtd:
            simpleapi.DeleteWorkspace(outputWs_name)

        result = simpleapi.CompareWorkspaces(workspace1_test, workspace2_test)

        self.assertTrue(isinstance(result, tuple))

        simpleapi.DeleteWorkspace(ws1_name)
        simpleapi.DeleteWorkspace(ws2_name)
Esempio n. 25
0
    def test_alg_produces_correct_workspace_in_APS_from_python(self):
        dataX=numpy.linspace(start=1,stop=3,num=11)
        dataY=numpy.linspace(start=1,stop=3,num=10)
        workspace1_test = simpleapi.CreateWorkspace(DataX=dataX, dataY=dataY, NSpec=1)
        workspace2_test = simpleapi.CloneWorkspace(workspace1_test)

        ws1_name = "workspace1_test"
        ws2_name = "workspace2_test"

        self.assertTrue(ws1_name in mtd)
        self.assertTrue(ws2_name in mtd)

        outputWs_name = "message"

        if outputWs_name in mtd:
            simpleapi.DeleteWorkspace(outputWs_name)

        result, message = simpleapi.CompareWorkspaces(workspace1_test, workspace2_test)

        self.assertTrue(outputWs_name in mtd)

        simpleapi.DeleteWorkspace(message)
        simpleapi.DeleteWorkspace(ws1_name)
        simpleapi.DeleteWorkspace(ws2_name)
Esempio n. 26
0
 def test_function_accepts_EnableLogging_keyword(self):
     # The test here is that the algorithm runs without falling over about the EnableLogging keyword being a property
     wsname = 'test_function_call_executes_correct_algorithm_when_passed_correct_args'
     data = [1.0,2.0,3.0,4.0,5.0]
     simpleapi.CreateWorkspace(data,data,OutputWorkspace=wsname,NSpec=1,UnitX='Wavelength',EnableLogging=False)
     self.assertTrue(wsname in mtd)
Esempio n. 27
0
 def test_function_call_executes_when_algorithm_has_only_inout_workspace_props(self):
     data = [1.0,2.0,3.0,4.0,5.0, 6.0]
     wavelength = simpleapi.CreateWorkspace(data,data,NSpec=3,UnitX='Wavelength')
     simpleapi.MaskDetectors(wavelength,WorkspaceIndexList=[1,2])
Esempio n. 28
0
 def test_function_call_executes_with_output_workspace_on_lhs(self):
     data = [1.0,2.0,3.0,4.0,5.0]
     wavelength = simpleapi.CreateWorkspace(data,data,NSpec=1,UnitX='Wavelength') # noqa F841
     self.assertTrue('wavelength' in mtd)
Esempio n. 29
0
 def test_function_call_executes_correct_algorithm_when_passed_correct_args(self):
     wsname = 'test_function_call_executes_correct_algorithm_when_passed_correct_args'
     data = [1.0,2.0,3.0,4.0,5.0]
     simpleapi.CreateWorkspace(data,data,OutputWorkspace=wsname,NSpec=1,UnitX='Wavelength')
     self.assertTrue( wsname in mtd )
Esempio n. 30
0
 def test_function_uses_OutputWorkspace_keyword_over_lhs_var_name_if_provided(self):
     wsname = 'test_function_uses_OutputWorkspace_keyword_over_lhs_var_name_if_provided'
     data = [1.0,2.0,3.0,4.0,5.0]
     wkspace = simpleapi.CreateWorkspace(data,data,OutputWorkspace=wsname,NSpec=1,UnitX='Wavelength') # noqa F841
     self.assertTrue( wsname in mtd )