MCPcopy Create free account
hub / github.com/apache/arrow / test_non_cpu_array

Function test_non_cpu_array

python/pyarrow/tests/test_array.py:4319–4401  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4317
4318
4319def test_non_cpu_array():
4320 cuda = pytest.importorskip("pyarrow.cuda")
4321 ctx = cuda.Context(0)
4322
4323 data = np.arange(4, dtype=np.int32)
4324 validity = np.array([True, False, True, False], dtype=np.bool_)
4325 cuda_data_buf = ctx.buffer_from_data(data)
4326 cuda_validity_buf = ctx.buffer_from_data(validity)
4327 arr = pa.Array.from_buffers(pa.int32(), 4, [None, cuda_data_buf])
4328 arr2 = pa.Array.from_buffers(pa.int32(), 4, [None, cuda_data_buf])
4329 arr_with_nulls = pa.Array.from_buffers(
4330 pa.int32(), 4, [cuda_validity_buf, cuda_data_buf])
4331
4332 # Supported
4333 arr.validate()
4334 assert arr.offset == 0
4335 assert arr.buffers() == [None, cuda_data_buf]
4336 assert arr.device_type == pa.DeviceAllocationType.CUDA
4337 assert arr.is_cpu is False
4338 assert len(arr) == 4
4339 assert arr.slice(2, 2).offset == 2
4340 assert repr(arr)
4341 assert str(arr)
4342
4343 # TODO support DLPack for CUDA
4344 with pytest.raises(NotImplementedError):
4345 arr.__dlpack__()
4346 with pytest.raises(NotImplementedError):
4347 arr.__dlpack_device__()
4348
4349 # Not Supported
4350 with pytest.raises(NotImplementedError):
4351 arr.diff(arr2)
4352 with pytest.raises(NotImplementedError):
4353 arr.cast(pa.int64())
4354 with pytest.raises(NotImplementedError):
4355 arr.view(pa.int64())
4356 with pytest.raises(NotImplementedError):
4357 arr.sum()
4358 with pytest.raises(NotImplementedError):
4359 arr.unique()
4360 with pytest.raises(NotImplementedError):
4361 arr.dictionary_encode()
4362 with pytest.raises(NotImplementedError):
4363 arr.value_counts()
4364 with pytest.raises(NotImplementedError):
4365 arr_with_nulls.null_count
4366 with pytest.raises(NotImplementedError):
4367 arr.nbytes
4368 with pytest.raises(NotImplementedError):
4369 arr.get_total_buffer_size()
4370 with pytest.raises(NotImplementedError):
4371 [i for i in iter(arr)]
4372 with pytest.raises(NotImplementedError):
4373 arr == arr2
4374 with pytest.raises(NotImplementedError):
4375 arr.is_null()
4376 with pytest.raises(NotImplementedError):

Callers

nothing calls this directly

Calls 15

lenFunction · 0.85
buffersMethod · 0.80
__dlpack__Method · 0.80
__dlpack_device__Method · 0.80
is_nullMethod · 0.80
filterMethod · 0.80
arrayMethod · 0.45
validateMethod · 0.45
sliceMethod · 0.45
castMethod · 0.45
viewMethod · 0.45
sumMethod · 0.45

Tested by

no test coverage detected