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


Python FORA.makeSymbol方法代码示例

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


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

示例1: test_extractPausedComputationDuringVectorLoad

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

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

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

        context.evaluate(
            FORA.extractImplValContainer(FORA.eval("fun() { [1,2,3].paged }")),
            FORANative.ImplValContainer(FORANative.makeSymbol("Call"))
            )

        pagedVec = context.getFinishedResult().asResult.result

        context.placeInEvaluationState(
            FORANative.ImplValContainer(
                (pagedVec,
                FORANative.ImplValContainer(FORANative.makeSymbol("GetItem")),
                FORANative.ImplValContainer(0))
                )
            )

        vdm.unloadAllPossible()

        context.resume()

        self.assertTrue(context.isVectorLoad())

        computation = context.extractPausedComputation()

        self.assertEqual(len(computation.frames),1)
开发者ID:Sandy4321,项目名称:ufora,代码行数:37,代码来源:ExecutionContext_test.py

示例2: test_futures_tupleCallInContinuation_2

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import makeSymbol [as 别名]
    def test_futures_tupleCallInContinuation_2(self):
        text = "fun(x) { x = x + x; size((x, *x)) }"

        cfg = self.parseStringToFunction(text).toCFG(1)

        x = 1
        xImplVal = ForaNative.ImplValContainer(x)
        cfgWithFutures = ForaNative.CFGWithFutures.createCfgWithFutures(
            cfg, "block_1Let", (xImplVal,))

        cfgWithFutures.continueSimulation()
        cfgWithFutures.continueSimulation()

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

        x = x + x
        cfgWithFutures.slotCompleted(
            0, normalComputationResult(
                ForaNative.ImplValContainer(x)
                )
            )

        self.assertFalse(cfgWithFutures.hasResolvedToSimpleState())

        self.assertEqual(cfgWithFutures.indicesOfSubmittableFutures(), [1])
        self.assertComponentwiseEqual(
            cfgWithFutures.submittableArgs(1).args.values,
            [ForaNative.makeSymbol("size"), ForaNative.makeSymbol("Call"),
             ForaNative.ImplValContainer((x, x))]
            )
开发者ID:Sandy4321,项目名称:ufora,代码行数:32,代码来源:CFGWithFutures_test.py

示例3: test_vectorOfPagedVectorApplyWithDropping

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import makeSymbol [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

示例4: test_resolveAxiomDirectly_smallStrings

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import makeSymbol [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

示例5: test_vecWithinVec

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import makeSymbol [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

示例6: test_expensive_brownian

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import makeSymbol [as 别名]
    def test_expensive_brownian(self):
        self.desirePublisher.desireNumberOfWorkers(2, blocking=True)

        expr = FORA.extractImplValContainer(
            FORA.eval(
                """fun() {
                    let brownian = fun(x,t) {
                        if (t == 0)
                            return sum(0.0, x * 10.0**7.0)
                        else
                            {
                            let (l,r) = cached(brownian(x - 1, t - 1), brownian(x + 1, t - 1));
                            return sum(0.0, x * 10.0**7.0) + l + r
                            }
                        }
                    brownian(0, 5)
                    }"""
                    )
            )

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

        self.assertTrue(response[1].isResult())
开发者ID:vishnur,项目名称:ufora,代码行数:30,代码来源:TestBase.py

示例7: test_sortALargeVectorWithFourWorkers

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import makeSymbol [as 别名]
    def test_sortALargeVectorWithFourWorkers(self):
        self.desirePublisher.desireNumberOfWorkers(4, blocking=True)
        
        expr = FORA.extractImplValContainer(
            FORA.eval(
                """fun() {
                    let v = Vector.range(12500000, {_%3.1415926});

                    if (sorting.isSorted(sorting.sort(v))) 'sorted'
                    }"""
                    )
            )

        try:
            response = self.evaluateWithGateway(
                makeComputationDefinitionFromIVCs(
                    expr,
                    ForaNative.makeSymbol("Call")
                    ),
                timeout=120.0
                )
        except Queue.Empty:
            response = None

        if response is None:
            try:
                dumpFun = self.dumpSchedulerEventStreams
                dumpFun()
            except:
                logging.warn("Wanted to dump CumulusWorkerEvents, but couldn't");


        self.assertTrue(response is not None)
        self.assertTrue(response[1].isResult())
        self.assertTrue(response[1].asResult.result.pyval == 'sorted', response[1].asResult.result.pyval)
开发者ID:vishnur,项目名称:ufora,代码行数:37,代码来源:TestBase.py

示例8: test_sortManySmallVectors

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import makeSymbol [as 别名]
    def test_sortManySmallVectors(self):
        self.desirePublisher.desireNumberOfWorkers(4, blocking=True)
        
        expr = FORA.extractImplValContainer(
            FORA.eval(
                """fun() {
                    let shouldAllBeTrue = 
                    Vector.range(20, fun(o) {
                        sorting.isSorted(
                            sort(Vector.range(50000 + o, fun(x) { x / 10 }))
                            )
                        });
                    for s in shouldAllBeTrue {
                        if (not s)
                            return false
                        }

                    return true
                    }"""
                    )
            )

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

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

示例9: test_manyDuplicateCachecallsAndAdding

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import makeSymbol [as 别名]
    def test_manyDuplicateCachecallsAndAdding(self):
        self.desirePublisher.desireNumberOfWorkers(2, blocking=True)
        
        expr = FORA.extractImplValContainer(
            FORA.eval(
                """fun() { 
                    Vector.range(20).papply(fun(x) { 
                        x + cached(sum(0,10**11))[0]
                        })
                    }"""
                    )
            )

        computationId = self.gateway.requestComputation(
            makeComputationDefinitionFromIVCs(
                expr,
                ForaNative.makeSymbol("Call")
                )
            )

        time.sleep(5)
        
        self.desirePublisher.desireNumberOfWorkers(4, blocking=True)

        try:
            response = self.gateway.finalResponses.get(timeout=240.0)
        except Queue.Empty:
            response = None

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

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

示例10: __init__

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import makeSymbol [as 别名]
    def __init__(self, pyforaBuiltinsModule):
        self.pyforaBuiltinsModule = pyforaBuiltinsModule
        self.pythonNameToInstance = {}
        self.instanceToPythonName = {}

        self.pyExceptionClass = pyforaBuiltinsModule.getObjectMember("PyException")
        self.pyAbortExceptionClass = pyforaBuiltinsModule.getObjectMember("PyAbortException")

        self.pyExceptionClassInstanceName = ForaNative.simulateApply(
            ForaNative.ImplValContainer(
                (self.pyExceptionClass,
                    ForaNative.makeSymbol("CreateInstance"),
                    ForaNative.ImplValContainer(),
                    ForaNative.ImplValContainer()
                    )
                )
            ).getClassName()

        self.pyAbortExceptionClassInstanceName = ForaNative.simulateApply(
            ForaNative.ImplValContainer(
                (self.pyAbortExceptionClass,
                 ForaNative.makeSymbol("CreateInstance"),
                 ForaNative.ImplValContainer(),
                 ForaNative.ImplValContainer()
                 )
                )
            ).getClassName()

        self.pythonNameToPyforaName = {}
        self.pythonNameToPyforaName.update(
            NamedSingletons.pythonNameToPyforaName
            )
        self.pythonNameToPyforaName.update(
            PyAbortSingletons.pythonNameToPyforaName
            )

        for pyName, pyforaName in self.pythonNameToPyforaName.iteritems():
            try:
                instance = FORA.ForaValue.FORAValue(pyforaBuiltinsModule).__getattr__(pyforaName).implVal_
            except:
                logging.error(
                    "Initializing PyforaSingletonAndExceptionConverter failed:"+
                        " couldn't find %s in the pyfora builtins", pyforaName)
                raise

            self.pythonNameToInstance[pyName] = instance
            self.instanceToPythonName[instance] = pyName
开发者ID:Sandy4321,项目名称:ufora,代码行数:49,代码来源:PyforaSingletonAndExceptionConverter.py

示例11: test_resumePausedComputationWithResult

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import makeSymbol [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

示例12: __getattr__

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import makeSymbol [as 别名]
    def __getattr__(self, attr):
        if attr.startswith('__') and attr.endswith('__'):
            raise AttributeError() # we don't want to intercept special python methods

        return processComputationResult(
            Evaluator.evaluator().evaluate(
                self.implVal_,
                FORAValue.symbol_Member.implVal_,
                ForaNative.makeSymbol(attr)
                )
            )
开发者ID:Sandy4321,项目名称:ufora,代码行数:13,代码来源:ForaValue.py

示例13: createComputation

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import makeSymbol [as 别名]
    def createComputation(self, expressionText, **freeVariables):
        varNames = list(freeVariables.keys())

        expr = FORA.eval("fun(" + ",".join(varNames) + ") {" + expressionText + " } ")

        return createComputationDefinition(
                FORA.extractImplValContainer(
                    expr
                    ),
                ForaNative.makeSymbol("Call"),
                *[freeVariables[v] for v in varNames]
                )
开发者ID:nkhuyu,项目名称:ufora,代码行数:14,代码来源:InMemoryCumulusSimulation.py

示例14: test_simple_computation

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import makeSymbol [as 别名]
    def test_simple_computation(self):
        self.desirePublisher.desireNumberOfWorkers(2, blocking=True)

        simpleFunc = FORA.extractImplValContainer(FORA.eval("fun(){1 + 2}"))

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

        self.assertEqual(3, response[1].asResult.result.pyval)
开发者ID:vishnur,项目名称:ufora,代码行数:15,代码来源:TestBase.py

示例15: calculateTime

# 需要导入模块: from ufora.native import FORA [as 别名]
# 或者: from ufora.native.FORA import makeSymbol [as 别名]
        def calculateTime(count):
            t0 = time.time()
            response = self.evaluateWithGateway(
                makeComputationDefinitionFromIVCs(
                    expr,
                    ForaNative.makeSymbol("Call"),
                    ForaNative.ImplValContainer(count)
                    )
                )

            self.assertTrue(response[1].isResult())

            stats = response[2]

            return (stats.timeSpentInInterpreter, stats.timeSpentInCompiler, time.time() - t0)
开发者ID:vishnur,项目名称:ufora,代码行数:17,代码来源:TestBase.py


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