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

Function test_import_device_no_cuda

python/pyarrow/tests/test_cffi.py:785–803  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

783
784@needs_cffi
785def test_import_device_no_cuda():
786 try:
787 import pyarrow.cuda # noqa
788 except ImportError:
789 pass
790 else:
791 pytest.skip("pyarrow.cuda is available")
792
793 c_array = ffi.new("struct ArrowDeviceArray*")
794 ptr_array = int(ffi.cast("uintptr_t", c_array))
795 arr = pa.array([1, 2, 3], type=pa.int64())
796 arr._export_to_c_device(ptr_array)
797
798 # patch the device type of the struct, this results in an invalid ArrowDeviceArray
799 # but this is just to test we raise am error before actually importing buffers
800 c_array.device_type = 2 # ARROW_DEVICE_CUDA
801
802 with pytest.raises(ImportError, match="Trying to import data on a CUDA device"):
803 pa.Array._import_from_c_device(ptr_array, arr.type)

Callers

nothing calls this directly

Calls 3

newMethod · 0.45
castMethod · 0.45
arrayMethod · 0.45

Tested by

no test coverage detected