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


Python testhelpers.run_algorithm函数代码示例

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


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

示例1: test_profileCoeffsNotSavedWhenNotRefined

    def test_profileCoeffsNotSavedWhenNotRefined(self):
        run_algorithm(self.ALG_NAME,
                      **self.defaultAlgParams)

        with h5py.File(self.TEMP_FILE_NAME, "r") as output_file:
            fit_results_group = output_file["Bank 1"]["GSAS-II Fitting"]
            self.assertFalse("Profile Coefficients" in fit_results_group)
开发者ID:mantidproject,项目名称:mantid,代码行数:7,代码来源:EnggSaveGSASIIFitResultsToHDF5Test.py

示例2: test_LoadWavelength

    def test_LoadWavelength(self):
        outputWorkspaceName = "LoadDNSLegacyTest_Test8"
        filename = "dn134011vana.d_dat"
        alg_test = run_algorithm("LoadDNSLegacy", Filename=filename, Normalization='no',
                                 OutputWorkspace=outputWorkspaceName, CoilCurrentsTable=self.curtable,
                                 Wavelength=5.7)

        self.assertTrue(alg_test.isExecuted())

        # Verify some values
        ws = AnalysisDataService.retrieve(outputWorkspaceName)
        # dimensions
        self.assertEqual(24, ws.getNumberHistograms())
        self.assertEqual(2,  ws.getNumDims())
        # data array
        self.assertEqual(31461, ws.readY(1))
        self.assertEqual(13340, ws.readY(23))
        self.assertAlmostEqual(5.7, ws.readX(1)[0], 3)
        self.assertAlmostEqual(5.7, ws.readX(23)[0], 3)
        # sample logs
        run = ws.getRun()
        self.assertEqual(5.7, run.getProperty('wavelength').value)
        self.assertAlmostEqual(2.51782, run.getProperty('Ei').value, 3)
        run_algorithm("DeleteWorkspace", Workspace=outputWorkspaceName)
        return
开发者ID:mantidproject,项目名称:mantid,代码行数:25,代码来源:LoadDNSLegacyTest.py

示例3: test_TwoTheta

    def test_TwoTheta(self):
        # check whether the 2theta angles the same as in the data workspace
        outputWorkspaceName = "DNSDetCorrVanaTest_Test5"
        # rotate detector bank to different angles
        api.LoadInstrument(self.__dataws, InstrumentName='DNS')
        api.LoadInstrument(self.__vanaws, InstrumentName='DNS')
        api.LoadInstrument(self.__bkgrws, InstrumentName='DNS')

        api.RotateInstrumentComponent(self.__dataws, "bank0", X=0, Y=1, Z=0, Angle=-7.53)
        api.RotateInstrumentComponent(self.__vanaws, "bank0", X=0, Y=1, Z=0, Angle=-8.02)
        api.RotateInstrumentComponent(self.__bkgrws, "bank0", X=0, Y=1, Z=0, Angle=-8.54)
        # run correction
        alg_test = run_algorithm("DNSDetEffCorrVana", InputWorkspace=self.__dataws.getName(),
                                 OutputWorkspace=outputWorkspaceName, VanaWorkspace=self.__vanaws.getName(),
                                 BkgWorkspace=self.__bkgrws.getName())
        self.assertTrue(alg_test.isExecuted())
        # check dimensions and angles
        ws = AnalysisDataService.retrieve(outputWorkspaceName)
        # dimensions
        self.assertEqual(24, ws.getNumberHistograms())
        self.assertEqual(2,  ws.getNumDims())
        # angles
        tthetas = np.array([7.53 + i*5 for i in range(24)])
        for i in range(24):
            det = ws.getDetector(i)
            self.assertAlmostEqual(tthetas[i], np.degrees(ws.detectorSignedTwoTheta(det)))

        run_algorithm("DeleteWorkspace", Workspace=outputWorkspaceName)
        return
开发者ID:stothe2,项目名称:mantid,代码行数:29,代码来源:DNSDetEffCorrVanaTest.py

示例4: test_LoadPartiallyValidFilesMultipleLogValues

    def test_LoadPartiallyValidFilesMultipleLogValues(self):
        outputWorskapceName = "LoadLogPropertyTableTest_Test2"

        alg_test = run_algorithm(
            "LoadLogPropertyTable",
            FirstFile="emu00006473.nxs",
            LastFile="emu00006475.nxs",
            LogNames="Temp_Sample,dur",
            OutputWorkspace=outputWorskapceName,
        )

        self.assertTrue(alg_test.isExecuted())

        # Verify some values
        tablews = AnalysisDataService.retrieve(outputWorskapceName)
        self.assertEqual(2, tablews.rowCount())
        self.assertEqual(3, tablews.columnCount())

        self.assertEqual(6473, tablews.cell(0, 0))
        self.assertAlmostEqual(200.078, tablews.cell(0, 1), 2)
        self.assertEqual("8697", tablews.cell(0, 2))
        self.assertEqual(6475, tablews.cell(1, 0))
        self.assertAlmostEqual(283.523, tablews.cell(1, 1), 2)
        self.assertEqual("5647", tablews.cell(1, 2))

        run_algorithm("DeleteWorkspace", Workspace=outputWorskapceName)

        return
开发者ID:spaceyatom,项目名称:mantid,代码行数:28,代码来源:LoadLogPropertyTableTest.py

示例5: test_setTitle

 def test_setTitle(self):        
     run_algorithm('CreateWorkspace', OutputWorkspace='ws1',DataX=[1.,2.,3.], DataY=[2.,3.], DataE=[2.,3.],UnitX='TOF')
     ws1 = AnalysisDataService['ws1']
     title = 'test_title'
     ws1.setTitle(title)
     self.assertEquals(title, ws1.getTitle())
     AnalysisDataService.remove(ws1.getName())
开发者ID:trnielsen,项目名称:mantid,代码行数:7,代码来源:MatrixWorkspaceTest.py

示例6: test_LoadValidFilesComments

    def test_LoadValidFilesComments(self):
        outputWorskapceName = "LoadLogPropertyTableTest_Test1"

        alg_test = run_algorithm(
            "LoadLogPropertyTable",
            FirstFile="MUSR00015189.nxs",
            LastFile="MUSR00015193.nxs",
            LogNames="comment",
            OutputWorkspace=outputWorskapceName,
        )

        self.assertTrue(alg_test.isExecuted())

        # Verify some values
        tablews = AnalysisDataService.retrieve(outputWorskapceName)
        self.assertEqual(5, tablews.rowCount())
        self.assertEqual(2, tablews.columnCount())

        self.assertEqual("18.95MHz 100W", tablews.cell(0, 1))
        self.assertEqual(15189, tablews.cell(0, 0))
        self.assertEqual(15193, tablews.cell(4, 0))

        run_algorithm("DeleteWorkspace", Workspace=outputWorskapceName)

        return
开发者ID:spaceyatom,项目名称:mantid,代码行数:25,代码来源:LoadLogPropertyTableTest.py

示例7: test_ChildAlg_call_with_output_and_input_ws_the_same_succeeds

 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,exc:
         self.fail("Algorithm call failed: %s" % str(exc))
开发者ID:trnielsen,项目名称:mantid,代码行数:7,代码来源:PythonAlgorithmChildAlgCallTest.py

示例8: testZeroMasking

 def testZeroMasking(self):
     ws = self._cloneTestWorkspace()
     zeroIndices = [5, 23]
     for i in zeroIndices:
         ws.dataY(i).fill(0.)
     eppWSName = 'eppWS'
     self._EPPTable(ws, eppWSName)
     outWSName = 'outWS'
     algProperties = {
         'InputWorkspace': self._TEST_WS_NAME,
         'OutputWorkspace': outWSName,
         'EPPWorkspace': eppWSName,
         'rethrow': True
     }
     run_algorithm('DirectILLIntegrateVanadium', **algProperties)
     self.assertTrue(mtd.doesExist(outWSName))
     outWS = mtd[outWSName]
     self.assertEquals(outWS.getNumberHistograms(), ws.getNumberHistograms())
     self.assertEquals(outWS.blocksize(), 1)
     spectrumInfo = outWS.spectrumInfo()
     for i in range(outWS.getNumberHistograms()):
         if i in zeroIndices:
             self.assertEquals(outWS.readY(i)[0], 0.)
             self.assertTrue(spectrumInfo.isMasked(i))
         else:
             self.assertGreater(outWS.readY(i)[0], 0.)
             self.assertFalse(spectrumInfo.isMasked(i))
开发者ID:mantidproject,项目名称:mantid,代码行数:27,代码来源:DirectILLIntegrateVanadiumTest.py

示例9: test_updateDouble

    def test_updateDouble(self):
        """ Test for update a double value
        """
        # tablews = self.create_TableWorkspace()

        alg_init = run_algorithm("CreateEmptyTableWorkspace", OutputWorkspace="TestTableWorkspace")
        self.assertTrue(alg_init.isExecuted())

        tablews = AnalysisDataService.retrieve("TestTableWorkspace")

        tablews.addColumn("str", "Name")
        tablews.addColumn("double", "Value")
        tablews.addColumn("str", "FitOrTie")

        tablews.addRow(["A", 1.34, "Fit"])
        tablews.addRow(["B", 2.34, "Tie"])
        tablews.addRow(["S", 3.34, "Tie"])

        alg_test = run_algorithm("UpdatePeakParameterTableValue", InputWorkspace=alg_init.getPropertyValue("OutputWorkspace"),
                Column="Value", ParameterNames=["A"], NewFloatValue=1.00)
        
        self.assertTrue(alg_test.isExecuted())

        newvalue_A = tablews.cell(0, 1)

        self.assertEqual(newvalue_A,  1.00)

        return
开发者ID:AlistairMills,项目名称:mantid,代码行数:28,代码来源:UpdatePeakParameterTableValueTest.py

示例10: testSuccessWhenEverythingDisabled

 def testSuccessWhenEverythingDisabled(self):
     outWSName = 'outWS'
     algProperties = {
         'InputWorkspace': self._TEST_WS_NAME,
         'OutputWorkspace': outWSName,
         'FlatBkg': 'Flat Bkg OFF',
         'IncidentEnergyCalibration': 'Energy Calibration OFF',
         'Normalisation': 'Normalisation OFF',
         'ElasticChannel': 'Default Elastic Channel',
         'rethrow': True
     }
     run_algorithm('DirectILLCollectData', **algProperties)
     self.assertTrue(mtd.doesExist(outWSName))
     outWS = mtd[outWSName]
     inWS = mtd[self._TEST_WS_NAME]
     self.assertEquals(outWS.getNumberHistograms(), inWS.getNumberHistograms() - 1)
     xs = outWS.extractX()
     originalXs = inWS.extractX()
     numpy.testing.assert_almost_equal(xs, originalXs[1:, :])
     ys = outWS.extractY()
     originalYs = inWS.extractY()
     numpy.testing.assert_almost_equal(ys, originalYs[1:, :])
     es = outWS.extractE()
     originalEs = inWS.extractE()
     numpy.testing.assert_almost_equal(es, originalEs[1:, :])
开发者ID:DanNixon,项目名称:mantid,代码行数:25,代码来源:DirectILLCollectDataTest.py

示例11: test_save_one_histogram

    def test_save_one_histogram(self):
        """ Test to Save one histogram
        """
        datawsname = "TestOneHistogram"
        E, I, err = self._createOneHistogram(datawsname)

        # Execute
        out_path = "tempout_hist.json"
        alg_test = run_algorithm(
            "SavePlot1DAsJson",
            InputWorkspace = datawsname,
            JsonFilename = out_path)
        # Executed?
        self.assertTrue(alg_test.isExecuted())
        # Verify ....
        d = json.load(open(out_path))
        d0 = d[datawsname+'0'] # plots are numbered
        np.testing.assert_array_equal(d0['x'], E)
        np.testing.assert_array_equal(d0['y'], I)
        np.testing.assert_array_equal(d0['e'], err)
        # test overwrite
        alg_test = run_algorithm(
            "SavePlot1DAsJson",
            InputWorkspace = datawsname,
            JsonFilename = out_path)
        # Delete the output file
        os.remove(out_path)
        return
开发者ID:stothe2,项目名称:mantid,代码行数:28,代码来源:SavePlot1DAsJsonTest.py

示例12: test_LoadTOF

    def test_LoadTOF(self):
        outputWorkspaceName = "LoadDNSLegacyTest_Test7"
        filename = "dnstof.d_dat"
        tof1 = 424.668     # must be changed if L1 will change
        alg_test = run_algorithm("LoadDNSLegacy", Filename=filename, Normalization='no',
                                 OutputWorkspace=outputWorkspaceName)
        self.assertTrue(alg_test.isExecuted())

        # Verify some values
        ws = AnalysisDataService.retrieve(outputWorkspaceName)
        # dimensions
        self.assertEqual(24, ws.getNumberHistograms())
        self.assertEqual(100,  ws.getNumberBins())
        # data array
        self.assertEqual(8, ws.readY(19)[37])       # must be changed after comissioning will be finished
        self.assertAlmostEqual(tof1, ws.readX(0)[0], 3)
        self.assertAlmostEqual(tof1+40.1*100, ws.readX(0)[100], 3)
        # sample logs
        run = ws.getRun()
        self.assertEqual(-7.5, run.getProperty('deterota').value)
        self.assertEqual(100, run.getProperty('tof_channels').value)
        self.assertEqual(51428, run.getProperty('mon_sum').value)
        self.assertEqual('z', run.getProperty('polarisation').value)
        self.assertEqual(33, run.getProperty('EPP').value)  # check that EPP is taken from file
        self.assertEqual('7', str(run.getProperty('polarisation_comment').value))
        self.assertEqual('no', run.getProperty('normalized').value)
        # check whether detector bank is rotated
        det = ws.getDetector(0)
        self.assertAlmostEqual(7.5, ws.detectorSignedTwoTheta(det)*180/pi)
        run_algorithm("DeleteWorkspace", Workspace=outputWorkspaceName)
        return
开发者ID:DanNixon,项目名称:mantid,代码行数:31,代码来源:LoadDNSLegacyTest.py

示例13: testDetectorGroupingWithUserGivenAngleStep

 def testDetectorGroupingWithUserGivenAngleStep(self):
     ws = illhelpers.create_poor_mans_in5_workspace(0.0, _groupingTestDetectors)
     nhisto = ws.getNumberHistograms()
     spectrumInfo = ws.spectrumInfo()
     minAngle = 180.
     maxAngle = 0.
     for i in range(nhisto):
         angle = numpy.rad2deg(spectrumInfo.twoTheta(i))
         minAngle = min(minAngle, angle)
         maxAngle = max(maxAngle, angle)
     mtd.addOrReplace('inWS', ws)
     outWSName = 'unused'
     outSThetaWName = 'SofThetaW'
     angleStep = 0.2
     algProperties = {
         'InputWorkspace': ws,
         'OutputWorkspace': outWSName,
         'GroupingAngleStep': angleStep,
         'OutputSofThetaEnergyWorkspace': outSThetaWName,
         'Transposing': 'Transposing OFF',
         'rethrow': True
     }
     run_algorithm('DirectILLReduction', **algProperties)
     self.assertTrue(outSThetaWName in mtd)
     SThetaWWS = mtd[outSThetaWName]
     spectrumInfo = SThetaWWS.spectrumInfo()
     firstAngleBin = int(minAngle / angleStep)
     lastAngleBin = int(maxAngle / angleStep) + 1
     expected = lastAngleBin - firstAngleBin
     self.assertEqual(spectrumInfo.size(), expected)
开发者ID:mantidproject,项目名称:mantid,代码行数:30,代码来源:DirectILLReductionTest.py

示例14: test_DNSMomentumTransfer

    def test_DNSMomentumTransfer(self):
        outputWorkspaceName = "DNSMergeRunsTest_Test4"
        alg_test = run_algorithm("DNSMergeRuns", WorkspaceNames=self.workspaces,
                                 OutputWorkspace=outputWorkspaceName, HorizontalAxis='|Q|')

        self.assertTrue(alg_test.isExecuted())
        # check whether the data are correct
        ws = AnalysisDataService.retrieve(outputWorkspaceName)
        # dimensions
        self.assertEqual(96, ws.blocksize())
        self.assertEqual(2,  ws.getNumDims())
        self.assertEqual(1,  ws.getNumberHistograms())
        # data array
        # reference values
        ttheta = np.round(np.radians(self.angles), 4)
        qarr = np.sort(4.0*np.pi*np.sin(0.5*ttheta)/4.2)
        # read the merged values
        dataX = ws.extractX()[0]
        for i in range(len(self.angles)):
            self.assertAlmostEqual(qarr[i], dataX[i])
        # check that the intensity has not been changed
        dataY = ws.extractY()[0]
        for i in range(len(dataY)):
            self.assertAlmostEqual(1.0, dataY[i])
        run_algorithm("DeleteWorkspace", Workspace=outputWorkspaceName)
        return
开发者ID:dezed,项目名称:mantid,代码行数:26,代码来源:DNSMergeRunsTest.py

示例15: test_save_one_histogram

    def test_save_one_histogram(self):
        """ Test to Save one histogram
        """
        datawsname = "TestOneHistogram"
        E, I, err = self._createOneHistogram(datawsname)

        # Execute
        out_path = "tempout_hist.json"
        alg_test = run_algorithm(
            "SavePlot1DAsJson",
            InputWorkspace = datawsname,
            JsonFilename = out_path)
        # Executed?
        self.assertTrue(alg_test.isExecuted())
        # Verify ....
        d = json.load(open(out_path))[datawsname]
        self._checkData(d, E, I, err)
        # test overwrite
        alg_test = run_algorithm(
            "SavePlot1DAsJson",
            InputWorkspace = datawsname,
            JsonFilename = out_path)
        # Delete the output file
        os.remove(out_path)
        return
开发者ID:liyulun,项目名称:mantid,代码行数:25,代码来源:SavePlot1DAsJsonTest.py


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