本文整理汇总了Python中ufora.FORA.python.FORA类的典型用法代码示例。如果您正苦于以下问题:Python FORA类的具体用法?Python FORA怎么用?Python FORA使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FORA类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getObjectMember_4
def test_getObjectMember_4(self):
obj = FORA.extractImplValContainer(
FORA.eval("object { x: fun () { } }")
)
obj2 = obj.getObjectMember('x')
self.assertTrue(obj2 is not None)
示例2: test_future_fuzz_5
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)
示例3: test_sortManySmallVectors
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)
示例4: createCliqueFinderContext
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
示例5: test_sortALargeVectorWithFourWorkers
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)
示例6: test_vecWithinVec
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)
示例7: test_teardown_during_vector_load
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()
示例8: test_teardown_simple
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)
示例9: test_manyDuplicateCachecallsAndAdding
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)
示例10: test_serialize_while_holding_interior_vector
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
示例11: test_extractPausedComputationDuringVectorLoad
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)
示例12: test_verifyThatExtractingPausedComputationsDoesntDuplicateLargeStrings
def test_verifyThatExtractingPausedComputationsDoesntDuplicateLargeStrings(self):
text = """fun() {
let s = ' '
while (size(s) < 1000000)
s = s + s
let f = fun(x) { if (x > 0) return f(x-1) + s[x]; `TriggerInterruptForTesting() }
f(20)
}"""
vdm = FORANative.VectorDataManager(callbackScheduler, Setup.config().maxPageSizeInBytes)
context = ExecutionContext.ExecutionContext(
dataManager = vdm,
allowInterpreterTracing = False
)
context.evaluate(
FORA.extractImplValContainer(FORA.eval(text)),
FORANative.symbol_Call
)
computation = context.extractPausedComputation()
context2 = ExecutionContext.ExecutionContext(
dataManager = vdm,
allowInterpreterTracing = False
)
context2.resumePausedComputation(computation)
self.assertTrue(
context2.totalBytesUsed < 2 * context.totalBytesUsed
)
示例13: test_refcountsInCompiledCode
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_expensive_brownian
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())
示例15: test_getObjectMember_3
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)