| 46 | |
| 47 | |
| 48 | def 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) |