def test_get_by_index_float32(self): src = np.random.rand(5).astype(np.float32) src_gpu = gpuarray.to_gpu(src) ind = gpuarray.to_gpu(np.array([0, 2, 4])) res_gpu = misc.get_by_index(src_gpu, ind) assert np.allclose(res_gpu.get(), src[[0, 2, 4]]) ind = gpuarray.to_gpu(np.array([], np.int64)) res_gpu = misc.get_by_index(src_gpu, ind) assert len(res_gpu) == 0
def test_get_by_index_float64(self): src = np.random.rand(5).astype(np.float64) src_gpu = gpuarray.to_gpu(src) ind = gpuarray.to_gpu(np.array([0, 2, 4])) res_gpu = misc.get_by_index(src_gpu, ind) assert_allclose(res_gpu.get(), src[[0, 2, 4]], rtol=dtype_to_rtol[np.float64], atol=dtype_to_atol[np.float64]) ind = gpuarray.to_gpu(np.array([], np.int64)) res_gpu = misc.get_by_index(src_gpu, ind) assert_equal(len(res_gpu), 0)