示例#1
0
def test_all(type, shape):
    size = 1
    for i in range(len(shape)):
        size *= shape[i]

    for i in range(2**size):
        t = i

        a = numpy.empty(size, dtype=type)

        for j in range(size):
            a[j] = 0 if t % 2 == 0 else j + 1
            t = t >> 1

        a = a.reshape(shape)

        ia = dpnp.array(a)

        np_res = numpy.all(a)
        dpnp_res = dpnp.all(ia)
        numpy.testing.assert_allclose(dpnp_res, np_res)

        np_res = a.all()
        dpnp_res = ia.all()
        numpy.testing.assert_allclose(dpnp_res, np_res)
    def test_imag_inplace(self, dtype):
        x = cupy.zeros((2, 3), dtype=dtype)

        # TODO(kmaehashi) The following line should raise error for real
        # dtypes, but currently ignored silently.
        x.imag[:] = 1

        expected = cupy.zeros(
            (2, 3), dtype=dtype) + (1j if x.dtype.kind == 'c' else 0)
        assert cupy.all(x == expected)
示例#3
0
    def all(self, axis=None, out=None, keepdims=False):
        """
        Returns True if all elements evaluate to True.

        Refer to `numpy.all` for full documentation.

        See Also
        --------
        :obj:`numpy.all` : equivalent function

        """

        return dpnp.all(self, axis, out, keepdims)
 def test_real_inplace(self, dtype):
     x = cupy.zeros((2, 3), dtype=dtype)
     x.real[:] = 1
     expected = cupy.ones((2, 3), dtype=dtype)
     assert cupy.all(x == expected)