本文整理汇总了Python中ufora.FORA.python.FORA.extractImplValContainer方法的典型用法代码示例。如果您正苦于以下问题:Python FORA.extractImplValContainer方法的具体用法?Python FORA.extractImplValContainer怎么用?Python FORA.extractImplValContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ufora.FORA.python.FORA
的用法示例。
在下文中一共展示了FORA.extractImplValContainer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_switch_nodes_1
# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import extractImplValContainer [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)
)
示例2: test_cached_nodes_1
# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import extractImplValContainer [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
)
示例3: createCliqueFinderContext
# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import extractImplValContainer [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
示例4: test_futures_with_branching_1
# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import extractImplValContainer [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)
)
示例5: test_teardown_simple
# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import extractImplValContainer [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)
示例6: evalApplyTuple
# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import extractImplValContainer [as 别名]
def evalApplyTuple(applyTuple, signature = None):
varNames = map(lambda ix: "x_%s" % ix, range(len(applyTuple)))
if signature is None:
evalStringTerms = varNames
else:
evalStringTerms = []
for ix in range(len(signature.terms)):
term = signature.terms[ix]
if term.isNormal():
name = term.asNormal.name
if name is not None:
evalStringTerms.append("%s: x_%s" % (name, ix))
else:
evalStringTerms.append("x_%s" % ix)
elif term.isTupleCall():
evalStringTerms.append("*x_%s" % ix)
evalString = evalStringTerms[0] + "`(" + ",".join(evalStringTerms[1:]) + ")"
try:
return normalComputationResult(
FORA.extractImplValContainer(
FORA.eval(
evalString,
locals = { name: val
for (name, val) in
zip(varNames, applyTuple) },
keepAsForaValue = True
)
)
)
except ForaValue.FORAException as e:
return exceptionComputationResult(
FORA.extractImplValContainer(e.foraVal)
)
示例7: test_resumePausedComputationWithResult
# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import extractImplValContainer [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)
示例8: test_vectorOfPagedVectorApplyWithDropping
# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import extractImplValContainer [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)
示例9: test_sortManySmallVectors
# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import extractImplValContainer [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)
示例10: test_getObjectMember_4
# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import extractImplValContainer [as 别名]
def test_getObjectMember_4(self):
obj = FORA.extractImplValContainer(
FORA.eval("object { x: fun () { } }")
)
obj2 = obj.getObjectMember('x')
self.assertTrue(obj2 is not None)
示例11: test_getObjectMember_3
# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import extractImplValContainer [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)
示例12: test_future_fuzz_5
# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import extractImplValContainer [as 别名]
def test_future_fuzz_5(self):
cfg = self.parseStringToFunction(
"fun(f) { f(1) + f(2) + f(3) + f(4) }").toCFG(1)
nodeValues = (FORA.extractImplValContainer(
FORA.eval("fun(x) { if (x <= 2) throw x else x + 1 }")),)
self.fuzz(cfg, nodeValues, 10)
示例13: test_refcountsInCompiledCode
# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import extractImplValContainer [as 别名]
def test_refcountsInCompiledCode(self):
vdm = FORANative.VectorDataManager(callbackScheduler, Setup.config().maxPageSizeInBytes)
context = ExecutionContext.ExecutionContext(
dataManager = vdm,
allowInterpreterTracing = True,
blockUntilTracesAreCompiled = True
)
text = """fun(){
let f = fun(v, depth) {
if (depth > 100)
//this will trigger an interrupt since the data cannot exist in the VDM
datasets.s3('','')
else
f(v, depth+1)
}
f([1,2,3,4,5], 0)
}"""
context.evaluate(
FORA.extractImplValContainer(FORA.eval(text)),
FORANative.symbol_Call
)
stacktraceText = context.extractCurrentTextStacktrace()
self.assertTrue(stacktraceText.count("Vector") < 10)
示例14: test_teardown_during_vector_load
# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import extractImplValContainer [as 别名]
def test_teardown_during_vector_load(self):
vdm = FORANative.VectorDataManager(callbackScheduler, Setup.config().maxPageSizeInBytes)
context = ExecutionContext.ExecutionContext(dataManager = vdm)
context.evaluate(
FORA.extractImplValContainer(
FORA.eval("fun() { let v = [1,2,3].paged; fun() { v[1] } }")
),
FORANative.symbol_Call
)
vdm.unloadAllPossible()
pagedVecAccessFun = context.getFinishedResult().asResult.result
context.teardown()
context.evaluate(
pagedVecAccessFun,
FORANative.symbol_Call
)
self.assertFalse(context.isInterrupted())
self.assertTrue(context.isVectorLoad())
context.teardown()
示例15: test_serialize_while_holding_interior_vector
# 需要导入模块: from ufora.FORA.python import FORA [as 别名]
# 或者: from ufora.FORA.python.FORA import extractImplValContainer [as 别名]
def test_serialize_while_holding_interior_vector(self):
vdm = FORANative.VectorDataManager(callbackScheduler, Setup.config().maxPageSizeInBytes)
context = ExecutionContext.ExecutionContext(dataManager = vdm, allowInterpreterTracing=False)
context.evaluate(
FORA.extractImplValContainer(
FORA.eval("""
fun() {
let v = [[1].paged].paged;
let v2 = v[0]
`TriggerInterruptForTesting()
1+2+3+v+v2
}"""
)
),
FORANative.symbol_Call
)
self.assertTrue(context.isInterrupted())
serialized = context.serialize()
context = None