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


Python FORA.parseStringToJOV方法代码示例

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


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

示例1: test_TypedFora_Layout_UsingCompiler

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import parseStringToJOV [as 别名]
    def test_TypedFora_Layout_UsingCompiler(self):
        layoutStyles = [
            TypedFora.RefcountStyle.Pooled(),
            TypedFora.RefcountStyle.AsValueUnowned(),
            TypedFora.RefcountStyle.AsValueOwned()
            ]

        jovs = [
            ForaNative.parseStringToJOV("{String}"),
            #a small union
            ForaNative.parseStringToJOV("{Union([{String}, {Int64}])}"),
            #a much bigger union
            ForaNative.parseStringToJOV("{Union([{String}, {Int64}, {Float64}, nothing, ({Float64})])}"),

            ForaNative.parseStringToJOV("'%s'" % aBigString),
            ForaNative.parseStringToJOV("*")
            ]

        for ls1 in layoutStyles:
            for jov1 in jovs:
                for ls2  in layoutStyles:
                    for jov2 in jovs:
                        if not (ls1.isAsValueOwned() and ls2.isAsValueUnowned()):
                            t1 = TypedFora.Type(jov1, ls1)
                            t2 = TypedFora.Type(jov2, ls2)
                            self.runSimpleEvaluation(t1, t2)
开发者ID:Sandy4321,项目名称:ufora,代码行数:28,代码来源:Layout_test.py

示例2: test_TypedFora_CreateTuple

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import parseStringToJOV [as 别名]
    def test_TypedFora_CreateTuple(self):
        layoutStyles = [
            TypedFora.RefcountStyle.Pooled(),
            TypedFora.RefcountStyle.AsValueUnowned(),
            TypedFora.RefcountStyle.AsValueOwned()
            ]

        jovs = [
            ForaNative.parseStringToJOV("{String}"),
            ForaNative.parseStringToJOV("'a string'"),
            ForaNative.parseStringToJOV("*")
            ]

        aVal = ForaNative.ImplValContainer("a string")

        allLayouts = []

        for ls1 in layoutStyles:
            for jov1 in jovs:
                allLayouts.append(TypedFora.Type(jov1, ls1))

        for t1 in allLayouts:
            for t2 in allLayouts:
                callable = self.generateTupleCallable([t1, t2], [False, False])

                def validator(result):
                    return result == ForaNative.ImplValContainer((aVal, aVal))

                self.runSimpleEvaluation(callable, [aVal, aVal], validator)
开发者ID:Sandy4321,项目名称:ufora,代码行数:31,代码来源:CreateTupleExpression_test.py

示例3: testMatchStructureCantMatchTooSmallTuple

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import parseStringToJOV [as 别名]
    def testMatchStructureCantMatchTooSmallTuple(self):
        runtime = Runtime.getMainRuntime()
        axioms = runtime.getAxioms()

        jov = FORANative.parseStringToJOV("((1,2,3),`StructureMatch,((nothing, false), (nothing, false), (nothing, false), (nothing, false)))")

        axiom = axioms.getAxiomByJOVT(runtime.getTypedForaCompiler(), jov.asTuple.jov)

        self.assertTrue(list(axiom.asNative.resultSignature.resultPart().vals) == [FORANative.parseStringToJOV("nothing")])
开发者ID:Sandy4321,项目名称:ufora,代码行数:11,代码来源:TupleMatchStructureAxiom_test.py

示例4: test_TypedFora_TupleGetItem

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import parseStringToJOV [as 别名]
    def test_TypedFora_TupleGetItem(self):
        tupJovs = [
            ForaNative.parseStringToJOV("({String}, {String})"),
            ForaNative.parseStringToJOV("({String}, *)"),
            ForaNative.parseStringToJOV("({String}, 'a string 2')"),
            ForaNative.parseStringToJOV("('a string', 'a string 2')"),
            ForaNative.parseStringToJOV("('a string', *)"),
            ForaNative.parseStringToJOV("('a string', {String})"),
            ForaNative.parseStringToJOV("(*, 'a string 2')"),
            ForaNative.parseStringToJOV("(*, *)"),
            ForaNative.parseStringToJOV("(*, {String})")
            ]

        layoutStyles = [
            TypedFora.RefcountStyle.Pooled(),
            TypedFora.RefcountStyle.AsValueUnowned(),
            TypedFora.RefcountStyle.AsValueOwned()
            ]

        instance = ForaNative.ImplValContainer( ("a string", "a string 2") )

        for tupJov in tupJovs:
            for refcountStyle in layoutStyles:
                for index in range(2):
                    type = TypedFora.Type(tupJov, refcountStyle)

                    callable = self.generateTupleGetitemCallable(type, index)

                    def validator(result):
                        return result == instance[index]

                    self.runSimpleEvaluation(callable, [instance], validator)
开发者ID:Sandy4321,项目名称:ufora,代码行数:34,代码来源:CreateTupleExpression_test.py

示例5: test_resolveAxiomDirectly_VeryLongComputation

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import parseStringToJOV [as 别名]
    def test_resolveAxiomDirectly_VeryLongComputation(self):
        vectorIVC = FORA.extractImplValContainer(FORA.eval("[]"))

        jov = ForaNative.parseStringToJOV(("({Vector([])}, `append, 2)"))

        joa = self.axioms.resolveAxiomDirectly(self.compiler, jov.getTuple())

        self.assertEqual(len(joa.throwPart()),0)
        self.assertEqual(len(joa.resultPart()),1)

        result = joa.resultPart()[0]

        self.assertEqual(result, ForaNative.parseStringToJOV("{Vector([{Int64}])}"))
开发者ID:Sandy4321,项目名称:ufora,代码行数:15,代码来源:Compiler_test.py

示例6: reasonAboutExpression

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import parseStringToJOV [as 别名]
    def reasonAboutExpression(self, expression, **variableJudgments):
        reasoner = FORANative.SimpleForwardReasoner(self.compiler, self.axioms, False)
        keys = sorted(list(variableJudgments.keys()))

        functionText = "fun(" + ",".join(['_'] + keys) + ") { " + expression + " }"

        frame = reasoner.reason(
            makeJovt(
                FORANative.parseStringToJOV(functionText), 
                *[FORANative.parseStringToJOV(variableJudgments[k]) for k in keys]
                )
            )

        self.dumpReasonerSummary(reasoner, frame)

        return frame
开发者ID:vishnur,项目名称:ufora,代码行数:18,代码来源:SimpleForwardReasoner_test.py

示例7: loadAxiomSignaturesFromFile

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import parseStringToJOV [as 别名]
 def loadAxiomSignaturesFromFile(self, axioms_file):
     """
     Loads axiom signatures from a file `axioms_file`. This file should contain
     axiom signatures on each line, but also can have commented lines (starting with a `#`)
     or commented blocks (lines surrounded by lines of `\"""`), as in python syntax.
     """
     axiom_signatures = []
     line_number = 0
     in_comment = False
     assert os.path.exists(axioms_file), (
                     "unable to open file `%s'\n"
                     %axioms_file
                     )
     with open(axioms_file) as f:
         for line in f:
             line_number += 1
             if re.search('^"""', line):
                 in_comment = (in_comment != True) # in_comment = in_comment XOR True
                 continue
             if not in_comment and not re.search('^#', line) and len(line.strip()) > 0:
                 try:
                     axiom_signatures.append(FORANative.parseStringToJOV(
                                                             line.strip()).getTuple())
                 except Exception as inst:
                     logging.warn("unable to parse to JOV: `%s', %s:%s",
                                                         line.strip(), axioms_file, line_number)
                     raise inst
     return axiom_signatures
开发者ID:Sandy4321,项目名称:ufora,代码行数:30,代码来源:AxiomsConsistency_test.py

示例8: toJOV

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import parseStringToJOV [as 别名]
def toJOV(x):
    if isinstance(x, str):
        try:
            return FORANative.parseStringToJOV(x)
        except:
            assert False, "Failed to parse %s" % x
    return x
开发者ID:Sandy4321,项目名称:ufora,代码行数:9,代码来源:JudgmentOnValue_test.py

示例9: assertJOVParsesToItself

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import parseStringToJOV [as 别名]
 def assertJOVParsesToItself(self, jov, originalString):
     """verify that we can print this, parse it, and get the same thing back"""
     try:
         reparsedJOV = FORANative.parseStringToJOV(str(jov))
     except:
         self.assertTrue(False, "%s didn't parse as a JOV" % str(jov))
         return
     self.assertTrue(reparsedJOV == jov, "%s (str='%s') reparsed as %s. hashes are %s and %s" %
             (jov, originalString, reparsedJOV, jov.hash, reparsedJOV.hash)
         )
开发者ID:Sandy4321,项目名称:ufora,代码行数:12,代码来源:JudgmentOnValue_test.py

示例10: reasonAboutExpression

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import parseStringToJOV [as 别名]
    def reasonAboutExpression(self, expression, **variableJudgments):
        keys = sorted(list(variableJudgments.keys()))

        functionText = "fun(" + ",".join(['_'] + keys) + ") { " + expression + " }"

        frame = self.reasoner.reasonAboutApply(
            makeJovt(
                FORANative.parseStringToJOV(functionText), 
                *[FORANative.parseStringToJOV(variableJudgments[k]) 
                    if isinstance(variableJudgments[k],str) else variableJudgments[k] for k in keys]
                )
            )

        self.dumpReasonerSummary(self.reasoner, frame)

        #self.reasoner.compile(frame)

        #while self.compiler.anyCompilingOrPending():
        #    time.sleep(0.001)

        return frame
开发者ID:WantonSoup,项目名称:ufora,代码行数:23,代码来源:SimpleForwardReasoner_test.py

示例11: test_resolveAxiomDirectly_smallStrings

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import parseStringToJOV [as 别名]
    def test_resolveAxiomDirectly_smallStrings(self):
        instance = ForaNative.ImplValContainer(
            ("s1", ForaNative.makeSymbol("Operator"), ForaNative.makeSymbol("+"), "s2")
            )
        jov = ForaNative.implValToJOV(instance)
        joa = self.axioms.resolveAxiomDirectly(self.compiler, jov.getTuple())

        self.assertEqual(len(joa.throwPart()),0)
        self.assertEqual(len(joa.resultPart()),1)

        result = joa.resultPart()[0]

        self.assertEqual(result, ForaNative.parseStringToJOV('"s1s2"'))
开发者ID:Sandy4321,项目名称:ufora,代码行数:15,代码来源:Compiler_test.py

示例12: assertFrameHasResultJOVs

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import parseStringToJOV [as 别名]
    def assertFrameHasResultJOVs(self, frame, *resultJOVs):
        self.assertTrue(len(frame.unknownApplyNodes()) == 0)

        jovsToFind = []
        for resultJOV in resultJOVs:
            if isinstance(resultJOV, str):
                resultJOV = FORANative.parseStringToJOV(resultJOV)
            jovsToFind.append(resultJOV)
        resultJOVs = list(jovsToFind)

        for res in frame.exits().resultPart():
            self.assertTrue(res in jovsToFind, 
                "Code produced unexpected JOV: %s. Result was %s but expected %s" % 
                    (res, frame.exits().resultPart(), resultJOVs)
                )
            jovsToFind.remove(res)

        self.assertTrue(
            len(jovsToFind) == 0, 
            "Code didn't produce these jovs: %s. Produced %s instead." % 
                (jovsToFind, frame.exits().resultPart())
            )
开发者ID:vishnur,项目名称:ufora,代码行数:24,代码来源:SimpleForwardReasoner_test.py

示例13: getJOVTFromList

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import parseStringToJOV [as 别名]
    def getJOVTFromList(self, jovStringList):
        jovList = []
        for jovString in jovStringList:
            try:
                jovList.append(FORANative.parseStringToJOV(jovString))
            except Exception as e:
                try:
                    match = re.search(
                        "^JudgmentParseError: \(unknown identifier (\w+):",
                        str(e)
                        ).group(1)
                except Exception:
                    raise e
                if match:
                    if match in self.knownModulesAsConstantJOVs:
                        jovList.append(self.knownModulesAsConstantJOVs[match])
                    else:
                        raise e
                else:
                    raise e

        return FORANative.JOVListToJOVT(jovList)
开发者ID:Sandy4321,项目名称:ufora,代码行数:24,代码来源:AxiomJOA_test.py

示例14: assertFrameHasResultJOV

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import parseStringToJOV [as 别名]
    def assertFrameHasResultJOV(self, frame, resultJOV):
        if isinstance(resultJOV, str):
            resultJOV = FORANative.parseStringToJOV(resultJOV)

        self.assertTrue(len(frame.exits().resultPart().vals) == 1, frame.exits())
        self.assertEqual(frame.exits().resultPart()[0], resultJOV)
开发者ID:vishnur,项目名称:ufora,代码行数:8,代码来源:SimpleForwardReasoner_test.py

示例15: symbolJov

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import parseStringToJOV [as 别名]
def symbolJov(sym):
    return FORANative.parseStringToJOV("`" + sym)
开发者ID:vishnur,项目名称:ufora,代码行数:4,代码来源:SimpleForwardReasoner_test.py


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