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


Python AlgorithmFactory.exists方法代码示例

本文整理汇总了Python中mantid.api.AlgorithmFactory.exists方法的典型用法代码示例。如果您正苦于以下问题:Python AlgorithmFactory.exists方法的具体用法?Python AlgorithmFactory.exists怎么用?Python AlgorithmFactory.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mantid.api.AlgorithmFactory的用法示例。


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

示例1: skip

# 需要导入模块: from mantid.api import AlgorithmFactory [as 别名]
# 或者: from mantid.api.AlgorithmFactory import exists [as 别名]
    def skip(self):
        """
        Override and return a string depending on whether the directive
        should be skipped. If empty then the directive should be processed
        otherwise the string should contain the error message
        The default is to skip (and warn) if the algorithm is not known.

        Returns:
          str: Return error mesage string if the directive should be skipped
        """
        from mantid.api import AlgorithmFactory, FunctionFactory

        name, version = self.algorithm_name(), self.algorithm_version()
        msg = ""
        if version is None: # it is a fit function
            if name in FunctionFactory.getFunctionNames():
                return ""
            else:
                msg = "No fit function '%s', skipping directive" % name
        else:
            if AlgorithmFactory.exists(name, version):
                return ""
            else:
                msg = "No algorithm '%s' version '%d', skipping directive" % (name, version)

        # warn the user
        if len(msg) > 0:
            env = self.state.document.settings.env
            env.app.verbose(msg)
        return msg
开发者ID:liyulun,项目名称:mantid,代码行数:32,代码来源:base.py

示例2: genNewLinks

# 需要导入模块: from mantid.api import AlgorithmFactory [as 别名]
# 或者: from mantid.api.AlgorithmFactory import exists [as 别名]
def genNewLinks(links, algNames, pageName):
    
    repLinks = []
    
    for link in links:

        link = link.replace('`', '')
        link = link.replace('<', '')
        link = link.replace('>', '')
        link = link.replace('__', '')
        link = link.split()

        #Check length of link
        if len(link) > 2:
            print 'Unlikely to be an algorithm link with multiple words in it'
            repLinks.append(None)
            links_todo[pageName].append(link)      
        else:            
            name = link[0]
            if "-v" in name:
                name = name[:-3]
            #Check if the link is a concept
            print "Checking for",name
            if (AlgorithmFactory.exists(name)):
                newLink = ':ref:`algm-'+ name +'`'
                repLinks.append(newLink)
            else:
                #These are links that aren't algorithms but are single words links, likely to be links to concepts or similar
                print 'Not found in algorithm list'
                repLinks.append(None)
                links_todo[pageName].append(link)
    
    return repLinks
开发者ID:martyngigg,项目名称:alg2rst,代码行数:35,代码来源:convertLinks.py

示例3: AlignComponents

# 需要导入模块: from mantid.api import AlgorithmFactory [as 别名]
# 或者: from mantid.api.AlgorithmFactory import exists [as 别名]
        calTable.addRow([22, 2490.42282292])
        calTable.addRow([23, 2490.49334316])
        calTable.addRow([24, 2498.83911141])
        calTable.addRow([25, 2498.85314962])
        calTable.addRow([26, 2498.89526313])
        calTable.addRow([27, 2498.96544859])
        calTable.addRow([28, 2507.31101837])
        calTable.addRow([29, 2507.32498986])
        calTable.addRow([30, 2507.36690322])
        calTable.addRow([31, 2507.43675513])

        ws = mtd["testWS"]
        startPos = ws.getInstrument().getComponentByName(component).getPos()
        startRot = ws.getInstrument().getComponentByName(component).getRotation().getEulerAngles("YZX") #YZX
        AlignComponents(CalibrationTable="calTable",
                        Workspace="testWS",
                        ComponentList=component,
                        AlphaRotation=True)
        ws = mtd["testWS"]
        endPos = ws.getInstrument().getComponentByName(component).getPos()
        endRot = ws.getInstrument().getComponentByName(component).getRotation().getEulerAngles("YZX") #YZX
        self.assertEqual(startPos, endPos)
        self.assertAlmostEqual(endRot[0],45.0,places=0)
        self.assertEqual(startRot[1], endRot[1])
        self.assertEqual(startRot[2], endRot[2])

if __name__ == "__main__":
    # Only test is Algorithm is loaded
    if AlgorithmFactory.exists("AlignComponents"):
        unittest.main()
开发者ID:DanNixon,项目名称:mantid,代码行数:32,代码来源:AlignComponentsTest.py

示例4: UBMatrixBuilderTest

# 需要导入模块: from mantid.api import AlgorithmFactory [as 别名]
# 或者: from mantid.api.AlgorithmFactory import exists [as 别名]
class UBMatrixBuilderTest(unittest.TestCase):
    def setUp(self):
        self.builder = UBMatrixBuilder()
        self.valid_matrix = {
            u"_diffrn_orient_matrix_ub_11": u"-0.03",
            u"_diffrn_orient_matrix_ub_12": u"0.13",
            u"_diffrn_orient_matrix_ub_13": u"0.31",
            u"_diffrn_orient_matrix_ub_21": u"0.01",
            u"_diffrn_orient_matrix_ub_22": u"-0.31",
            u"_diffrn_orient_matrix_ub_23": u"0.14",
            u"_diffrn_orient_matrix_ub_31": u"0.34",
            u"_diffrn_orient_matrix_ub_32": u"0.02",
            u"_diffrn_orient_matrix_ub_33": u"0.02",
        }

    def test_getUBMatrix_invalid(self):
        for key in self.valid_matrix:
            tmp = self.valid_matrix.copy()
            del tmp[key]

            self.assertRaises(RuntimeError, self.builder._getUBMatrix, cifData=tmp)

    def test_getUBMatrix_correct(self):
        self.assertEqual(self.builder._getUBMatrix(self.valid_matrix), "-0.03,0.13,0.31,0.01,-0.31,0.14,0.34,0.02,0.02")


if __name__ == "__main__":
    # Only test if algorithm is registered (PyCifRW dependency).
    if AlgorithmFactory.exists("LoadCIF"):
        unittest.main()
开发者ID:rosswhitfield,项目名称:mantid,代码行数:32,代码来源:LoadCIFTest.py

示例5: test_exists_returns_correct_value_for_given_args

# 需要导入模块: from mantid.api import AlgorithmFactory [as 别名]
# 或者: from mantid.api.AlgorithmFactory import exists [as 别名]
 def test_exists_returns_correct_value_for_given_args(self):
     self.assertTrue(AlgorithmFactory.exists('ConvertUnits')) #any version
     self.assertTrue(AlgorithmFactory.exists('ConvertUnits', 1)) #any version
     self.assertTrue(not AlgorithmFactory.exists('ConvertUnits', 100)) #any version
开发者ID:BigShows,项目名称:mantid,代码行数:6,代码来源:AlgorithmFactoryTest.py


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