Ejemplo n.º 1
0
 def test_vdot(self, xp, dtype):
     a = testing.shaped_arange((5, ), xp, dtype)
     b = testing.shaped_reverse_arange((5, ), xp, dtype)
     return xp.vdot(a, b)
Ejemplo n.º 2
0
 def test_reversed_inner(self, xp, dtype):
     a = testing.shaped_arange((5, ), xp, dtype)[::-1]
     b = testing.shaped_reverse_arange((5, ), xp, dtype)[::-1]
     return xp.inner(a, b)
Ejemplo n.º 3
0
 def test_copysign_combination(self, xp, dtype_a, dtype_b):
     a = testing.shaped_arange((2, 3), xp, dtype_a)
     b = testing.shaped_reverse_arange((2, 3), xp, dtype_b)
     return xp.copysign(a, b)
Ejemplo n.º 4
0
 def test_nextafter_combination(self, xp, dtype_a, dtype_b):
     a = testing.shaped_arange((2, 3), xp, dtype_a)
     # skip 0 because cupy (may) handle denormals differently (-ftz=true)
     a[a == 0] = 1
     b = testing.shaped_reverse_arange((2, 3), xp, dtype_b)
     return xp.nextafter(a, b)
Ejemplo n.º 5
0
 def check_binary(self, name, xp, dtype, no_bool=False):
     if no_bool and numpy.dtype(dtype).char == '?':
         return numpy.int_(0)
     a = testing.shaped_arange((2, 3), xp, dtype)
     b = testing.shaped_reverse_arange((2, 3), xp, dtype)
     return getattr(xp, name)(a, b)
Ejemplo n.º 6
0
 def check_binary(self, name, xp, dtype):
     a = testing.shaped_arange((2, 3), xp, dtype)
     b = testing.shaped_reverse_arange((2, 3), xp, dtype)
     return getattr(xp, name)(a, b)
Ejemplo n.º 7
0
 def test_copyto_where(self, xp, dtype):
     a = testing.shaped_arange((2, 3, 4), xp, dtype)
     b = testing.shaped_reverse_arange((2, 3, 4), xp, dtype)
     c = testing.shaped_arange((2, 3, 4), xp, '?')
     xp.copyto(a, b, where=c)
     return a
Ejemplo n.º 8
0
 def test_real_setter(self, xp, dtype):
     x = testing.shaped_arange((2, 3), xp, dtype)
     x.real = testing.shaped_reverse_arange((2, 3), xp, dtype).real
     return x
Ejemplo n.º 9
0
 def test_imag_setter_raise(self, dtype):
     for xp in (numpy, cupy):
         x = testing.shaped_arange((2, 3), xp, dtype)
         with pytest.raises(TypeError):
             x.imag = testing.shaped_reverse_arange((2, 3), xp, dtype)
Ejemplo n.º 10
0
 def test_imag_setter_non_contiguous(self, xp, dtype):
     x = testing.shaped_arange((2, 3, 2), xp, dtype).transpose(0, 2, 1)
     x.imag = testing.shaped_reverse_arange((2, 2, 3), xp, dtype).real
     return x
Ejemplo n.º 11
0
        #         y = xp.asarray(y)
        #         y[y == numpy.inf] = numpy.nan
        #        y[y == -numpy.inf] = numpy.nan

        return y


@testing.gpu
@testing.parameterize(*(
    testing.product({
        # TODO(unno): boolean subtract causes DeprecationWarning in numpy>=1.13
        'arg1':
        [testing.shaped_arange((2, 3), numpy, dtype=d)
         for d in all_types] + [0, 0.0, 2, 2.0],
        'arg2': [
            testing.shaped_reverse_arange((2, 3), numpy, dtype=d)
            for d in all_types
        ] + [0, 0.0, 2, 2.0],
        'name': ['add', 'multiply', 'power', 'subtract'],
    }) + testing.product({
        'arg1':
        [numpy.array([-3, -2, -1, 1, 2, 3], dtype=d)
         for d in negative_types] + [0, 0.0, 2, 2.0, -2, -2.0],
        'arg2':
        [numpy.array([-3, -2, -1, 1, 2, 3], dtype=d)
         for d in negative_types] + [0, 0.0, 2, 2.0, -2, -2.0],
        'name': ['divide', 'true_divide', 'subtract'],
    })))
class TestArithmeticBinary(ArithmeticBinaryBase, unittest.TestCase):
    def test_binary(self):
        self.use_dtype = False