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

Function test_copy_to

python/pyarrow/tests/test_device.py:48–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46
47
48def test_copy_to():
49 mm = pa.default_cpu_memory_manager()
50
51 arr = pa.array([0, 1, 2])
52 batch = pa.record_batch({"col": arr})
53
54 for dest in [mm, mm.device]:
55 arr_copied = arr.copy_to(dest)
56 assert arr_copied.equals(arr)
57 assert arr_copied.buffers()[1].device == mm.device
58 assert arr_copied.buffers()[1].address != arr.buffers()[1].address
59
60 batch_copied = batch.copy_to(dest)
61 assert batch_copied.equals(batch)
62 assert batch_copied["col"].buffers()[1].device == mm.device
63 assert batch_copied["col"].buffers()[1].address != arr.buffers()[1].address
64
65 with pytest.raises(TypeError, match="Argument 'destination' has incorrect type"):
66 arr.copy_to(mm.device.device_type)
67
68 with pytest.raises(TypeError, match="Argument 'destination' has incorrect type"):
69 batch.copy_to(mm.device.device_type)

Callers

nothing calls this directly

Calls 3

equalsMethod · 0.80
buffersMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected