def test_empty_3d(self): image_format = cl.ImageFormat('CL_RGBA', 'CL_UNSIGNED_INT8') image = cl.empty_image(ctx, [4, 4, 4], image_format) self.assertEqual(image.type, cl.Image.IMAGE3D) self.assertEqual(image.image_format, image_format) self.assertEqual(image.image_width, 4) self.assertEqual(image.image_height, 4) self.assertEqual(image.image_depth, 4)
def test_map(self): image_format = cl.ImageFormat('CL_RGBA', 'CL_UNSIGNED_INT8') image = cl.empty_image(ctx, [4, 4], image_format) queue = Queue(ctx) with image.map(queue) as img: self.assertEqual(img.format, 'T{B:r:B:g:B:b:B:a:}') self.assertEqual(img.ndim, 2) self.assertEqual(img.shape, (4, 4)) array = np.asarray(img) array['r'] = 1 with image.map(queue) as img: array = np.asarray(img) self.assertTrue(np.all(array['r'] == 1))