Пример #1
0
 def test_compile(self):
     x = numpy_compile('aa+f*f/a-', 10)
     x = x.compute()
     assert isinstance(x, SingleDimArray)
     assert x.size == 10
     assert x.eval(0).val == 0
     assert x.eval(1).val == ((1 + 1) * 1.2) / 1.2 - 1
Пример #2
0
 def f(code):
     interp = numpy_compile(hlstr(code))
     interp.run(space)
     res = interp.results[-1]
     w_res = res.eval(0).wrap(interp.space)
     if isinstance(w_res, BoolObject):
         return float(w_res.boolval)
     elif isinstance(w_res, FloatObject):
         return w_res.floatval
     elif isinstance(w_res, IntObject):
         return w_res.intval
     else:
         return -42.
Пример #3
0
 def run(self, code):
     interp = numpy_compile(code)
     space = FakeSpace()
     interp.run(space)
     return interp
Пример #4
0
 def compile(self, code):
     return numpy_compile(code)
Пример #5
0
def main(bc, size):
    if not isinstance(bc, str):
        bc = hlstr(bc)  # for tests
    a = numpy_compile(bc, size)
    a = a.compute()
Пример #6
0
def main(bc, size):
    if not isinstance(bc, str):
        bc = hlstr(bc) # for tests
    a = numpy_compile(bc, size)
    a = a.compute()