示例#1
0
 def test_binop_signature(self, space):
     ar = SingleDimArray(10)
     v1 = ar.descr_add(space, ar)
     v2 = ar.descr_add(space, FloatWrapper(2.0))
     assert v1.signature is not v2.signature
     v3 = ar.descr_add(space, FloatWrapper(1.0))
     assert v2.signature is v3.signature
     v4 = ar.descr_add(space, ar)
     assert v1.signature is v4.signature
示例#2
0
 def f(i):
     ar = SingleDimArray(i, dtype=NonConstant(float64_dtype))
     j = 0
     while j < i:
         ar.get_concrete().setitem(j, float64_dtype.box(1.0))
         j += 1
     return ar.descr_add(space, ar).descr_all(space).boolval
示例#3
0
 def f(i):
     ar = SingleDimArray(i)
     j = 0
     while j < i:
         ar.get_concrete().storage[j] = float(j)
         j += 1
     return ar.descr_add(space, ar).descr_min(space)
示例#4
0
 def f(i):
     step = NonConstant(3)
     ar = SingleDimArray(step*i, dtype=float64_dtype)
     ar2 = SingleDimArray(i, dtype=float64_dtype)
     ar2.get_concrete().setitem(1, float64_dtype.box(5.5))
     arg = ar2.descr_add(space, ar2)
     ar.setslice(space, 0, step*i, step, i, arg)
     return ar.get_concrete().eval(3).val
示例#5
0
 def f(i):
     if NonConstant(False):
         dtype = int64_dtype
     else:
         dtype = float64_dtype
     ar = SingleDimArray(i, dtype=dtype)
     v = ar.descr_add(space, ar).descr_prod(space)
     assert isinstance(v, FloatObject)
     return v.floatval
示例#6
0
    def test_slice_signature(self, space):
        ar = SingleDimArray(10)
        v1 = ar.descr_getitem(space, space.wrap(slice(1, 5, 1)))
        v2 = ar.descr_getitem(space, space.wrap(slice(4, 6, 1)))
        assert v1.signature is v2.signature

        v3 = ar.descr_add(space, v1)
        v4 = ar.descr_add(space, v2)
        assert v3.signature is v4.signature
示例#7
0
 def f(i):
     step = NonConstant(3)
     ar = SingleDimArray(step*i)
     ar2 = SingleDimArray(i)
     ar2.storage[1] = 5.5
     if NonConstant(False):
         arg = ar2
     else:
         arg = ar2.descr_add(space, ar2)
     ar.setslice(space, 0, step*i, step, i, arg)
     return ar.get_concrete().storage[3]
示例#8
0
 def f(i):
     if NonConstant(False):
         dtype = int64_dtype
     else:
         dtype = float64_dtype
     ar = SingleDimArray(i, dtype=dtype)
     j = 0
     while j < i:
         ar.get_concrete().setitem(j, float64_dtype.box(float(j)))
         j += 1
     v = ar.descr_add(space, ar).descr_max(space)
     assert isinstance(v, FloatObject)
     return v.floatval
示例#9
0
 def f(n):
     if NonConstant(False):
         dtype = float64_dtype
     else:
         dtype = int32_dtype
     ar = SingleDimArray(n, dtype=dtype)
     i = 0
     while i < n:
         ar.get_concrete().setitem(i, int32_dtype.box(7))
         i += 1
     v = ar.descr_add(space, ar).descr_sum(space)
     assert isinstance(v, IntObject)
     return v.intval
示例#10
0
 def f(i):
     ar = SingleDimArray(i, dtype=NonConstant(float64_dtype))
     return ar.descr_add(space, ar).descr_any(space).boolval
示例#11
0
 def f(i):
     ar = SingleDimArray(i)
     return ar.descr_add(space, ar).descr_prod(space)