Esempio n. 1
0
    def test_slice_signature(self, space):
        float64_dtype = get_dtype_cache(space).w_float64dtype

        ar = W_NDimArray([10], dtype=float64_dtype)
        v1 = ar.descr_getitem(space, space.wrap(slice(1, 3, 1)))
        v2 = ar.descr_getitem(space, space.wrap(slice(4, 6, 1)))
        assert v1.find_sig() is v2.find_sig()

        v3 = v2.descr_add(space, v1)
        v4 = v1.descr_add(space, v2)
        assert v3.find_sig() is v4.find_sig()
        v5 = ar.descr_add(space, ar).descr_getitem(space,
                                                   space.wrap(slice(1, 3, 1)))
        v6 = ar.descr_add(space, ar).descr_getitem(space,
                                                   space.wrap(slice(1, 4, 1)))
        assert v5.find_sig() is v6.find_sig()
Esempio n. 2
0
 def f(n):
     if NonConstant(False):
         dtype = float64_dtype
     else:
         dtype = int32_dtype
     ar = W_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
Esempio n. 3
0
    def test_slice_signature(self, space):
        float64_dtype = get_dtype_cache(space).w_float64dtype

        ar = W_NDimArray([10], dtype=float64_dtype)
        v1 = ar.descr_getitem(space, space.wrap(slice(1, 3, 1)))
        v2 = ar.descr_getitem(space, space.wrap(slice(4, 6, 1)))
        assert v1.find_sig() is v2.find_sig()

        v3 = v2.descr_add(space, v1)
        v4 = v1.descr_add(space, v2)
        assert v3.find_sig() is v4.find_sig()
        v5 = ar.descr_add(space, ar).descr_getitem(space, space.wrap(slice(1, 3, 1)))
        v6 = ar.descr_add(space, ar).descr_getitem(space, space.wrap(slice(1, 4, 1)))
        assert v5.find_sig() is v6.find_sig()
Esempio n. 4
0
    def test_binop_signature(self, space):
        float64_dtype = get_dtype_cache(space).w_float64dtype
        bool_dtype = get_dtype_cache(space).w_booldtype

        ar = W_NDimArray(10, [10], dtype=float64_dtype)
        ar2 = W_NDimArray(10, [10], dtype=float64_dtype)
        v1 = ar.descr_add(space, ar)
        v2 = ar.descr_add(space, Scalar(float64_dtype, W_Float64Box(2.0)))
        sig1 = v1.find_sig()
        sig2 = v2.find_sig()
        assert v1 is not v2
        assert sig1.left.iter_no == sig1.right.iter_no
        assert sig2.left.iter_no != sig2.right.iter_no
        assert sig1.left.array_no == sig1.right.array_no
        sig1b = ar2.descr_add(space, ar).find_sig()
        assert sig1b.left.array_no != sig1b.right.array_no
        assert sig1b is not sig1
        v3 = ar.descr_add(space, Scalar(float64_dtype, W_Float64Box(1.0)))
        sig3 = v3.find_sig()
        assert sig2 is sig3
        v4 = ar.descr_add(space, ar)
        assert v1.find_sig() is v4.find_sig()

        bool_ar = W_NDimArray(10, [10], dtype=bool_dtype)
        v5 = ar.descr_add(space, bool_ar)
        assert v5.find_sig() is not v1.find_sig()
        assert v5.find_sig() is not v2.find_sig()
        v6 = ar.descr_add(space, bool_ar)
        assert v5.find_sig() is v6.find_sig()
        v7 = v6.descr_add(space, v6)
        sig7 = v7.find_sig()
        assert sig7.left.left.iter_no == sig7.right.left.iter_no
        assert sig7.left.left.iter_no != sig7.right.right.iter_no
        assert sig7.left.right.iter_no == sig7.right.right.iter_no
        v1.forced_result = ar
        assert v1.find_sig() is not sig1
Esempio n. 5
0
    def test_binop_signature(self, space):
        float64_dtype = get_dtype_cache(space).w_float64dtype
        bool_dtype = get_dtype_cache(space).w_booldtype

        ar = W_NDimArray([10], dtype=float64_dtype)
        ar2 = W_NDimArray([10], dtype=float64_dtype)
        v1 = ar.descr_add(space, ar)
        v2 = ar.descr_add(space, Scalar(float64_dtype, W_Float64Box(2.0)))
        sig1 = v1.find_sig()
        sig2 = v2.find_sig()
        assert v1 is not v2
        assert sig1.left.iter_no == sig1.right.iter_no
        assert sig2.left.iter_no != sig2.right.iter_no
        assert sig1.left.array_no == sig1.right.array_no
        sig1b = ar2.descr_add(space, ar).find_sig()
        assert sig1b.left.array_no != sig1b.right.array_no
        assert sig1b is not sig1
        v3 = ar.descr_add(space, Scalar(float64_dtype, W_Float64Box(1.0)))
        sig3 = v3.find_sig()
        assert sig2 is sig3
        v4 = ar.descr_add(space, ar)
        assert v1.find_sig() is v4.find_sig()

        bool_ar = W_NDimArray([10], dtype=bool_dtype)
        v5 = ar.descr_add(space, bool_ar)
        assert v5.find_sig() is not v1.find_sig()
        assert v5.find_sig() is not v2.find_sig()
        v6 = ar.descr_add(space, bool_ar)
        assert v5.find_sig() is v6.find_sig()
        v7 = v6.descr_add(space, v6)
        sig7 = v7.find_sig()
        assert sig7.left.left.iter_no == sig7.right.left.iter_no
        assert sig7.left.left.iter_no != sig7.right.right.iter_no
        assert sig7.left.right.iter_no == sig7.right.right.iter_no
        v1.forced_result = ar
        assert v1.find_sig() is not sig1