Skip to content

Commit 215f3f3

Browse files
author
Holger Kohr
committed
TST: add test for setitem in axis 0
1 parent 9f0fa41 commit 215f3f3

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

pygpu/tests/test_gpu_ndarray.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,14 @@ def getitem_none(shp):
310310
assert numpy.allclose(a_gpu[1:, None], a[1:, None])
311311

312312

313-
def test_mapping_setitem_ellipsis():
313+
def test_mapping_setitem():
314314
for shp in [(9,), (8, 9), (4, 8, 9), (1, 8, 9)]:
315315
for dtype in dtypes_all:
316316
for offseted in [True, False]:
317317
yield mapping_setitem_ellipsis, shp, dtype, offseted
318318
yield mapping_setitem_ellipsis2, shp, dtype, offseted
319+
yield mapping_setitem_firstaxis, shp, dtype, offseted
320+
319321

320322
@guard_devsup
321323
def mapping_setitem_ellipsis(shp, dtype, offseted):
@@ -324,13 +326,24 @@ def mapping_setitem_ellipsis(shp, dtype, offseted):
324326
a_gpu[...] = 2
325327
assert numpy.allclose(a, numpy.asarray(a_gpu))
326328

329+
327330
@guard_devsup
328331
def mapping_setitem_ellipsis2(shp, dtype, offseted):
329332
a, a_gpu = gen_gpuarray(shp, dtype, offseted, ctx=ctx)
330333
b, b_gpu = gen_gpuarray(shp[1:], dtype, False, ctx=ctx)
331334
a[:] = b
332335
a_gpu[:] = b_gpu
333-
assert numpy.allclose(a, numpy.asarray(b_gpu))
336+
assert numpy.allclose(a, numpy.asarray(a_gpu))
337+
338+
339+
@guard_devsup
340+
def mapping_setitem_firstaxis(shp, dtype, offseted):
341+
a, a_gpu = gen_gpuarray(shp, dtype, offseted, ctx=ctx)
342+
b, b_gpu = gen_gpuarray(shp[1:], dtype, False, ctx=ctx)
343+
a[0] = b
344+
a_gpu[0] = b_gpu
345+
assert numpy.allclose(a, numpy.asarray(a_gpu))
346+
334347

335348
class WriteReadTest(unittest.TestCase):
336349
def setUp(self):

0 commit comments

Comments
 (0)