()
| 4434 | |
| 4435 | |
| 4436 | def test_non_cpu_array(): |
| 4437 | cuda = pytest.importorskip("pyarrow.cuda", exc_type=ImportError) |
| 4438 | ctx = cuda.Context(0) |
| 4439 | |
| 4440 | data = np.arange(4, dtype=np.int32) |
| 4441 | validity = np.array([True, False, True, False], dtype=np.bool_) |
| 4442 | cuda_data_buf = ctx.buffer_from_data(data) |
| 4443 | cuda_validity_buf = ctx.buffer_from_data(validity) |
| 4444 | arr = pa.Array.from_buffers(pa.int32(), 4, [None, cuda_data_buf]) |
| 4445 | arr2 = pa.Array.from_buffers(pa.int32(), 4, [None, cuda_data_buf]) |
| 4446 | arr_with_nulls = pa.Array.from_buffers( |
| 4447 | pa.int32(), 4, [cuda_validity_buf, cuda_data_buf]) |
| 4448 | |
| 4449 | # Supported |
| 4450 | arr.validate() |
| 4451 | assert arr.offset == 0 |
| 4452 | assert arr.buffers() == [None, cuda_data_buf] |
| 4453 | assert arr.device_type == pa.DeviceAllocationType.CUDA |
| 4454 | assert arr.is_cpu is False |
| 4455 | assert len(arr) == 4 |
| 4456 | assert arr.slice(2, 2).offset == 2 |
| 4457 | assert repr(arr) |
| 4458 | assert str(arr) |
| 4459 | |
| 4460 | # TODO support DLPack for CUDA |
| 4461 | with pytest.raises(NotImplementedError): |
| 4462 | arr.__dlpack__() |
| 4463 | with pytest.raises(NotImplementedError): |
| 4464 | arr.__dlpack_device__() |
| 4465 | |
| 4466 | # Not Supported |
| 4467 | with pytest.raises(NotImplementedError): |
| 4468 | arr.diff(arr2) |
| 4469 | with pytest.raises(NotImplementedError): |
| 4470 | arr.cast(pa.int64()) |
| 4471 | with pytest.raises(NotImplementedError): |
| 4472 | arr.view(pa.int64()) |
| 4473 | with pytest.raises(NotImplementedError): |
| 4474 | arr.sum() |
| 4475 | with pytest.raises(NotImplementedError): |
| 4476 | arr.unique() |
| 4477 | with pytest.raises(NotImplementedError): |
| 4478 | arr.dictionary_encode() |
| 4479 | with pytest.raises(NotImplementedError): |
| 4480 | arr.value_counts() |
| 4481 | with pytest.raises(NotImplementedError): |
| 4482 | arr_with_nulls.null_count |
| 4483 | with pytest.raises(NotImplementedError): |
| 4484 | arr.nbytes |
| 4485 | with pytest.raises(NotImplementedError): |
| 4486 | arr.get_total_buffer_size() |
| 4487 | with pytest.raises(NotImplementedError): |
| 4488 | [i for i in iter(arr)] |
| 4489 | with pytest.raises(NotImplementedError): |
| 4490 | arr == arr2 |
| 4491 | with pytest.raises(NotImplementedError): |
| 4492 | arr.is_null() |
| 4493 | with pytest.raises(NotImplementedError): |
nothing calls this directly
no test coverage detected