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


Python FORA.eval方法代码示例

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


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

示例1: test_futures_with_branching_1

# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import eval [as 别名]
    def test_futures_with_branching_1(self):
        cfg = self.parseStringToFunction(
            "fun(x, f, g) { if (x) return f(x) else g(x) }").toCFG(3)
        fImplval = FORA.extractImplValContainer(FORA.eval("fun(x) { x + 1 }"))
        gImplVal = FORA.extractImplValContainer(FORA.eval("fun(x) { throw x }"))
        xImplVal = ForaNative.ImplValContainer(1)

        cfgWithFutures = ForaNative.CFGWithFutures.createCfgWithFutures(
            cfg, None, (xImplVal, fImplval, gImplVal))

        self.assertEqual(cfgWithFutures.currentLabel(), "block_0Branch")
        self.assertEqual(cfgWithFutures.indicesOfSubmittableFutures(), [])

        cfgWithFutures.continueSimulation()

        self.assertEqual(cfgWithFutures.currentLabel(), "block_1Return")
        self.assertEqual(cfgWithFutures.indicesOfSubmittableFutures(), [0])

        cfgWithFutures.slotCompleted(
            0, evalSubmittableArgs(cfgWithFutures.submittableArgs(0))
            )

        finalResult = cfgWithFutures.getFinalResult()

        self.assertEqual(
            finalResult.asResult.result.asResult.result,
            ForaNative.ImplValContainer(2)
            )
开发者ID:Sandy4321,项目名称:ufora,代码行数:30,代码来源:CFGWithFutures_test.py

示例2: test_teardown_simple

# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import eval [as 别名]
    def test_teardown_simple(self):
        vdm = FORANative.VectorDataManager(callbackScheduler, Setup.config().maxPageSizeInBytes)
        context = ExecutionContext.ExecutionContext(dataManager = vdm)

        context.evaluate(
            FORA.extractImplValContainer(
                FORA.eval("fun(){nothing}")
                ),
            FORANative.symbol_Call
            )

        context.getFinishedResult()

        toEval = FORA.extractImplValContainer(
            FORA.eval(
                """fun() {
                    let f = fun() { };
                    let v = [1, [3]];
                    cached(f())
                    }"""
                )
            )

        context.evaluate(toEval, FORANative.symbol_Call)
        while not context.isCacheRequest():
            context.resume()

        context.teardown(True)
开发者ID:Sandy4321,项目名称:ufora,代码行数:30,代码来源:ExecutionContext_test.py

示例3: test_switch_nodes_1

# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import eval [as 别名]
    def test_switch_nodes_1(self):
        text = "fun(x, f, g) { match (x) with (1) { f(x) } (2) { g(x) } }"
        cfg = self.parseStringToFunction(text).toCFG(3)
        fImplval = FORA.extractImplValContainer(FORA.eval("fun(x) { x + 1 }"))
        gImplVal = FORA.extractImplValContainer(FORA.eval("fun(x) { throw x }"))
        xImplVal = ForaNative.ImplValContainer(1)

        cfgWithFutures = ForaNative.CFGWithFutures.createCfgWithFutures(
            cfg, None, (xImplVal, fImplval, gImplVal))

        self.assertEqual(cfgWithFutures.currentLabel(), "block_0Try")
        self.assertEqual(cfgWithFutures.indicesOfSubmittableFutures(), [])

        cfgWithFutures.continueSimulation()

        self.assertEqual(cfgWithFutures.currentLabel(), "block_6Try")

        self.assertEqual(cfgWithFutures.indicesOfSubmittableFutures(), [0])

        cfgWithFutures.slotCompleted(
            0, evalSubmittableArgs(cfgWithFutures.submittableArgs(0))
            )

        finalResult = cfgWithFutures.getFinalResult()
        self.assertEqual(
            finalResult.asResult.result.asResult.result,
            ForaNative.ImplValContainer(2)
            )
开发者ID:Sandy4321,项目名称:ufora,代码行数:30,代码来源:CFGWithFutures_test.py

示例4: test_cached_nodes_1

# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import eval [as 别名]
    def test_cached_nodes_1(self):
        text = "fun(f, g) { cached(f(), g()); }"
        cfg = self.parseStringToFunction(text).toCFG(2)
        fImplval = FORA.extractImplValContainer(FORA.eval("fun() { 1 }"))
        gImplVal = FORA.extractImplValContainer(FORA.eval("fun() { 2 }"))

        cfgWithFutures = ForaNative.CFGWithFutures.createCfgWithFutures(
            cfg, None, (fImplval, gImplVal))

        self.assertEqual(cfgWithFutures.indicesOfSubmittableFutures(), [0])

        res = evalSubmittableArgs(cfgWithFutures.submittableArgs(0))

        expectedResult = ForaNative.ImplValContainer((1, 2))

        self.assertEqual(res.asResult.result, expectedResult)

        cfgWithFutures.slotCompleted(0, res)

        finalResult = cfgWithFutures.getFinalResult()

        self.assertEqual(
            finalResult.asResult.result.asResult.result,
            expectedResult
            )
开发者ID:Sandy4321,项目名称:ufora,代码行数:27,代码来源:CFGWithFutures_test.py

示例5: createCliqueFinderContext

# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import eval [as 别名]
    def createCliqueFinderContext(self, text, *args):
        maxPageSizeInBytes = 32 * 1024
        vdm = FORANative.VectorDataManager(callbackScheduler, maxPageSizeInBytes)

        context = ExecutionContext.ExecutionContext(
            dataManager = vdm
            )

        argumentImplvals = []

        for a in args:
            context.evaluate(
                FORA.extractImplValContainer(FORA.eval("fun() { " + a + " }")),
                Symbol_Call
                )

            argumentImplvals.append(
                context.getFinishedResult().asResult.result
                )

        actualFunction = FORA.extractImplValContainer(
            FORA.eval(text)
            )

        context.placeInEvaluationState(
            FORANative.ImplValContainer(
                (actualFunction, Symbol_Call) + tuple(argumentImplvals)
                )
            )
        
        return context, argumentImplvals, vdm
开发者ID:WantonSoup,项目名称:ufora,代码行数:33,代码来源:FuturesCliqueFinder_test.py

示例6: test_resumePausedComputationWithResult

# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import eval [as 别名]
    def test_resumePausedComputationWithResult(self):
        self.runtime = Runtime.getMainRuntime()
        #self.dynamicOptimizer = self.runtime.dynamicOptimizer

        vdm = FORANative.VectorDataManager(callbackScheduler, Setup.config().maxPageSizeInBytes)

        context = ExecutionContext.ExecutionContext(
            dataManager = vdm,
            allowInterpreterTracing = False
            )

        text = """
        let f = fun(v, ix) {
            if (ix > 0)
                {
                let (v2,res) = f(v,ix-1);
                return (v2, res + v2[0])
                }

            `TriggerInterruptForTesting()

            return (v, 0)
            };

        f([1], 10)
        """

        context.evaluate(
            FORA.extractImplValContainer(FORA.eval("fun() { " + text + " }")),
            FORANative.ImplValContainer(FORANative.makeSymbol("Call"))
            )

        assert context.isInterrupted()

        pausedComp = context.extractPausedComputation()

        framesToUse = pausedComp.frames[0:5]

        pausedComp2 = FORANative.PausedComputation(
            framesToUse,
            FORA.extractImplValContainer(FORA.eval("([2], 0)", keepAsForaValue=True)),
            False
            )

        context.resumePausedComputation(pausedComp2)

        context.copyValuesOutOfVectorPages()
        context.pageLargeVectorHandles(0)

        context.resetInterruptState()
        context.resume()

        self.assertTrue( context.isFinished() )

        result = context.getFinishedResult()

        self.assertTrue(result.asResult.result[1].pyval == 6)
开发者ID:Sandy4321,项目名称:ufora,代码行数:59,代码来源:ExecutionContext_test.py

示例7: test_vectorOfPagedVectorApplyWithDropping

# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import eval [as 别名]
    def test_vectorOfPagedVectorApplyWithDropping(self):
        self.desirePublisher.desireNumberOfWorkers(3, blocking=True)
        expr = FORA.extractImplValContainer(
            FORA.eval(
                """fun() {
                    let v =
                        Vector.range(20).apply(fun(ix) {
                            Vector.range(1250000.0+ix).paged
                            }).paged
                    let lookup = fun(ix) { v[ix] }
                    Vector.range(100).apply(fun(ix) { sum(0, 10**8); cached(lookup(ix)) })
                    v
                    }"""
                    )
            )
        computation1 = self.gateway.requestComputation(
            makeComputationDefinitionFromIVCs(
                expr,
                ForaNative.makeSymbol("Call")
                )
            )
        try:
            response = self.gateway.finalResponses.get(timeout=60.0)
        except Queue.Empty:
            response = None
        self.assertTrue(response is not None, response)

        self.gateway.deprioritizeComputation(computation1)

        self.desirePublisher.desireNumberOfWorkers(2, blocking=True)
        expr2 = FORA.extractImplValContainer(
            FORA.eval(
                """fun() {
                    let res = 0
                    for ix in sequence(10)
                        res = res + Vector.range(12500000+ix).sum()
                    return res
                    }"""
                    )
            )
        computation2 = self.gateway.requestComputation(
            makeComputationDefinitionFromIVCs(
                expr2,
                ForaNative.makeSymbol("Call")
                )
            )
        
        try:
            response = self.gateway.finalResponses.get(timeout=60.0)
        except Queue.Empty:
            response = None

        self.assertTrue(response is not None)
        self.assertTrue(response[1].isResult())

        self.gateway.deprioritizeComputation(computation2)
开发者ID:vishnur,项目名称:ufora,代码行数:58,代码来源:TestBase.py

示例8: test_deep_parse_trees_trigger_ParseErrors

# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import eval [as 别名]
 def test_deep_parse_trees_trigger_ParseErrors(self):
     sz = 1000
     s = "0 + "
     for i in range(sz - 1):
         s = s + "1 + "
     s = s + "1"
     try:
         Fora.eval(s)
         self.assertTrue(False)
     except ParseException:
         self.assertTrue(True)
开发者ID:Sandy4321,项目名称:ufora,代码行数:13,代码来源:Parser_test.py

示例9: test_serializationOfMutableVectors

# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import eval [as 别名]
    def test_serializationOfMutableVectors(self):
        #verify that if we serialize two copies of the same vector that we get the same
        #actual value back out
        mutVecPair = FORA.eval("let x = MutableVector(Float64).create(10, 0.0); (x,x)", keepAsForaValue = True)
        mutVecPairSer = FORA.extractImplValContainer(mutVecPair).serializeEntireObjectGraph()

        mutVecPair2 = ivc()
        mutVecPair2.deserializeEntireObjectGraph(mutVecPairSer)

        mutVecPair2 = FORA.ForaValue.FORAValue(mutVecPair2)

        self.assertTrue(FORA.eval("fun((x,y)) { x[0] = 1.0;  y[0] is 1.0 }")(mutVecPair2))
        self.assertTrue(FORA.eval("fun((x,y)) { x is y }")(mutVecPair2))
开发者ID:Sandy4321,项目名称:ufora,代码行数:15,代码来源:ImplVal_test.py

示例10: test_throwUpdatesVariables

# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import eval [as 别名]
    def test_throwUpdatesVariables(self):
        locals = {}
        try:
            FORA.eval("let x = 10; throw 20", locals)
            self.assertTrue(False)
        except ForaValue.FORAException as e:
            self.assertEqual(e.foraVal, 20)
            self.assertTrue(e.trace is not None)
            self.assertTrue(isinstance(e.trace, list))
            for l in e.trace:
                assert isinstance(l, HashNative.Hash)

        self.assertEqual(locals, {'x':10})
开发者ID:Sandy4321,项目名称:ufora,代码行数:15,代码来源:FORA_test.py

示例11: evalTimingsForExpr

# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import eval [as 别名]
def evalTimingsForExpr(expression, callResult = False):
    if callResult:
        toCall = FORA.eval(expression)
        evalFun = lambda n: FORA.eval(
            "toCall()",
            locals = { "toCall" : toCall },
            parsePath = ["LocalPerfTestRunner"]
            )
    else:
        evalFun = lambda n: FORA.eval(
            expression, parsePath = ["LocalPerfTestRunner"]
            )

    measureTimingsInLoop(evalFun)
开发者ID:Sandy4321,项目名称:ufora,代码行数:16,代码来源:ValidatePerf.py

示例12: test_tupleExpand_nodes_1

# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import eval [as 别名]
    def test_tupleExpand_nodes_1(self):
        text = "fun(h) { let (f, g) = h(); (f(), g()) }"
        cfg = self.parseStringToFunction(text).toCFG(1)
        hImplVal = FORA.extractImplValContainer(
            FORA.eval(
                "fun() { let f = fun() { 1 }; let g = fun() { 2 }; (f, g) }"
                )
            )

        cfgWithFutures = ForaNative.CFGWithFutures.createCfgWithFutures(
            cfg, None, (hImplVal,))

        res = evalSubmittableArgs(cfgWithFutures.submittableArgs(0))

        cfgWithFutures.slotCompleted(
            0, res
            )

        cfgWithFutures.continueSimulation()
        cfgWithFutures.continueSimulation()
        cfgWithFutures.continueSimulation()

        submittableArgs = cfgWithFutures.submittableArgs(1)
        cfgWithFutures.slotCompleted(
            1, evalSubmittableArgs(submittableArgs)
            )
        cfgWithFutures.continueSimulation()
        self.assertEqual(cfgWithFutures.indicesOfSubmittableFutures(), [2])

        # this verifies that parallelism is possible for `text`
        cfgWithFutures.continueSimulation()
        self.assertEqual(cfgWithFutures.indicesOfSubmittableFutures(), [2, 3])

        """
开发者ID:nkhuyu,项目名称:ufora,代码行数:36,代码来源:CFGWithFutures_test.py

示例13: test_vecWithinVec

# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import eval [as 别名]
    def test_vecWithinVec(self):
        self.desirePublisher.desireNumberOfWorkers(4, blocking=True)
        
        expr = FORA.extractImplValContainer(
            FORA.eval(
                """fun() {
                    let v = 
                        Vector.range(10) ~~ fun(x) {
                            Vector.range(1000000 + x).paged
                            };
                    v = v.paged;

                    let res = ()
                    for elt in v
                        res = res + (elt,)

                    res..apply(fun(tupElt) { tupElt.sum() })

                    'got to the end'
                    }"""
                    )
            )

        response = self.evaluateWithGateway(
            makeComputationDefinitionFromIVCs(
                expr,
                ForaNative.makeSymbol("Call")
                )
            )

        self.assertTrue(response[1].isResult())
        self.assertTrue(response[1].asResult.result.pyval == 'got to the end', response[1].asResult.result.pyval)
开发者ID:vishnur,项目名称:ufora,代码行数:34,代码来源:TestBase.py

示例14: test_createInstance_2

# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import eval [as 别名]
    def test_createInstance_2(self):
        classIvc = FORA.eval(
            """let C = class {
                   member y;
                   member x;
                   };
               C"""
        ).implVal_

        x = 1
        y = 2

        res = ForaNative.simulateApply(
            ForaNative.ImplValContainer(
                (
                    classIvc,
                    makeSymbolIvc("CreateInstance"),
                    ForaNative.ImplValContainer(y),
                    ForaNative.ImplValContainer(x),
                )
            )
        )

        self.assertIsNotNone(res)

        computed_x = ForaNative.simulateApply(
            ForaNative.ImplValContainer((res, self.Symbol_member, makeSymbolIvc("x")))
        )

        self.assertEqual(computed_x, ForaNative.ImplValContainer(x))
开发者ID:vishnur,项目名称:ufora,代码行数:32,代码来源:FunctionStage1Simulation_test.py

示例15: test_getObjectMember_3

# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import eval [as 别名]
    def test_getObjectMember_3(self):
        obj = FORA.extractImplValContainer(
            FORA.eval("object { x: object { y: 20 } }")
            )
        obj2 = obj.getObjectMember('x')

        self.assertEqual(obj2.getObjectMember('y').pyval, 20)
开发者ID:Sandy4321,项目名称:ufora,代码行数:9,代码来源:ImplVal_test.py


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