Пример #1
0
 def test_rolling_window(self):
     for shape, window, axis in [((3, 4), 2, 0), ((10, 30, 4), 4, -2)]:
         a = np.random.randn(*shape)
         a_rw = rolling_window(a, window, axis)
         b = cp.array(a)
         b_rw = rolling_window(b, window, axis)
         assert_array_equal(a_rw, b_rw)
Пример #2
0
    def check_func(x, y):
        if sp_name is not None:
            import scipy.sparse
            if cupyx.scipy.sparse.issparse(x):
                x = x.A
            if scipy.sparse.issparse(y):
                y = y.A

        array.assert_array_equal(x, y, err_msg, verbose, strides_check)
Пример #3
0
 def test_func(self, *args, **kw):
     kw[name] = cupy
     x = impl(self, *args, **kw)
     kw[name] = numpy
     y = impl(self, *args, **kw)
     self.assertIsNotNone(x)
     self.assertIsNotNone(y)
     array.assert_array_equal(x, y, err_msg, verbose)
     if type_check:
         self.assertEqual(x.dtype, y.dtype)
Пример #4
0
    def test_as_strided(self):
        a = cp.array([1, 2, 3, 4])
        a_view = as_strided(a, shape=(2, ), strides=(2 * a.itemsize, ))
        expected = cp.array([1, 3])
        assert_array_equal(a_view, expected)

        a = cp.array([1, 2, 3, 4])
        a_view = as_strided(a, shape=(3, 4), strides=(0, 1 * a.itemsize))
        expected = cp.array([[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]])
        assert_array_equal(a_view, expected)
Пример #5
0
 def test_func(self, *args, **kw):
     kw[name] = cupy
     x = impl(self, *args, **kw)
     kw[name] = numpy
     y = impl(self, *args, **kw)
     self.assertIsNotNone(x)
     self.assertIsNotNone(y)
     array.assert_array_equal(x, y, err_msg, verbose)
     if type_check:
         self.assertEqual(x.dtype, y.dtype)
Пример #6
0
 def check_func(x, y):
     array.assert_array_equal(x, y, err_msg, verbose)
Пример #7
0
 def check_func(x, y):
     array.assert_array_equal(x, y, err_msg, verbose)
Пример #8
0
 def test_func(self, *args, **kw):
     kw[name] = cupy
     x = impl(self, *args, **kw)
     kw[name] = numpy
     y = impl(self, *args, **kw)
     array.assert_array_equal(x, y, err_msg, verbose)