Beispiel #1
0
 def f(n):
     if NonConstant(False):
         dtype = float64_dtype
     else:
         dtype = int32_dtype
     ar = NDimArray(n, [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
Beispiel #2
0
    def test_binop_signature(self, space):
        float64_dtype = space.fromcache(interp_dtype.W_Float64Dtype)

        ar = NDimArray(10, [10], dtype=float64_dtype)
        v1 = ar.descr_add(space, ar)
        v2 = ar.descr_add(space, Scalar(float64_dtype, 2.0))
        assert v1.signature is not v2.signature
        v3 = ar.descr_add(space, Scalar(float64_dtype, 1.0))
        assert v2.signature is v3.signature
        v4 = ar.descr_add(space, ar)
        assert v1.signature is v4.signature

        bool_ar = NDimArray(10, [10], dtype=space.fromcache(interp_dtype.W_BoolDtype))
        v5 = ar.descr_add(space, bool_ar)
        assert v5.signature is not v1.signature
        assert v5.signature is not v2.signature
        v6 = ar.descr_add(space, bool_ar)
        assert v5.signature is v6.signature