def test_setitem_assign_to_slice():
a = numpy.arange(27)
a.resize((3, 3, 3))
a = theano._asarray(a, dtype='float32')
_a = cuda_ndarray.CudaNdarray(a)
b = theano._asarray([7, 8, 9], dtype='float32')
_b = cuda_ndarray.CudaNdarray(b)
# first get a slice of a
_c = _a[:, :, 1]
# set middle row through cube to 7,8,9
# (this corresponds to middle row of matrix _c)
_c[:, 1] = _b
a[:, :, 1][:, 1] = b
assert numpy.allclose(a, numpy.asarray(_a))
# test direct transfert from numpy
_d = _a[1, :, :]
_d[1, :] = b * 10
a[1, :, :][1, :] = b * 10
assert numpy.allclose(a, numpy.asarray(_a))
评论列表
文章目录