pitrou commented on PR #36453:
URL: https://github.com/apache/arrow/pull/36453#issuecomment-1620193210

   Can you integrate this patch to also fix Python warnings?
   ```diff
   diff --git a/python/pyarrow/tests/test_cuda.py 
b/python/pyarrow/tests/test_cuda.py
   index 2ba2f8267..43cd16a3c 100644
   --- a/python/pyarrow/tests/test_cuda.py
   +++ b/python/pyarrow/tests/test_cuda.py
   @@ -349,27 +349,29 @@ def test_HostBuffer(size):
    
    @pytest.mark.parametrize("size", [0, 1, 1000])
    def test_copy_from_to_host(size):
   -
        # Create a buffer in host containing range(size)
   -    buf = pa.allocate_buffer(size, resizable=True)  # in host
   +    dt = np.dtype('uint16')
   +    nbytes = size * dt.itemsize
   +    buf = pa.allocate_buffer(nbytes, resizable=True)  # in host
        assert isinstance(buf, pa.Buffer)
        assert not isinstance(buf, cuda.CudaBuffer)
   -    arr = np.frombuffer(buf, dtype=np.uint8)
   +    arr = np.frombuffer(buf, dtype=dt)
        assert arr.size == size
        arr[:] = range(size)
   -    arr_ = np.frombuffer(buf, dtype=np.uint8)
   +    arr_ = np.frombuffer(buf, dtype=dt)
        np.testing.assert_equal(arr, arr_)
    
   -    device_buffer = global_context.new_buffer(size)
   +    # Create a device buffer of the same size and copy from host
   +    device_buffer = global_context.new_buffer(nbytes)
        assert isinstance(device_buffer, cuda.CudaBuffer)
        assert isinstance(device_buffer, pa.Buffer)
   -    assert device_buffer.size == size
   +    assert device_buffer.size == nbytes
        assert not device_buffer.is_cpu
   +    device_buffer.copy_from_host(buf, position=0, nbytes=nbytes)
    
   -    device_buffer.copy_from_host(buf, position=0, nbytes=size)
   -
   -    buf2 = device_buffer.copy_to_host(position=0, nbytes=size)
   -    arr2 = np.frombuffer(buf2, dtype=np.uint8)
   +    # Copy back to host and compare contents
   +    buf2 = device_buffer.copy_to_host(position=0, nbytes=nbytes)
   +    arr2 = np.frombuffer(buf2, dtype=dt)
        np.testing.assert_equal(arr, arr2)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to