()
| 317 | @requires_numpy_version("2.2.5") |
| 318 | @check_bytes_allocated |
| 319 | def test_dlpack_copy_is_writeable(): |
| 320 | # NumPy did not set the writeable flag on DLPack imports before 2.2.5. |
| 321 | arr = pa.array([1, 2, 3], type=pa.int32()) |
| 322 | |
| 323 | # Arrow arrays are immutable, so a shared export is read-only |
| 324 | shared = np.from_dlpack(DLPackForwarder(arr, max_version=(1, 3))) |
| 325 | assert not shared.flags.writeable |
| 326 | |
| 327 | # A copy is solely owned by the consumer, who may mutate it |
| 328 | copied = np.from_dlpack(DLPackForwarder(arr, max_version=(1, 3), copy=True)) |
| 329 | assert copied.flags.writeable |
| 330 | copied[0] = 100 |
| 331 | assert arr.to_pylist() == [1, 2, 3] |
| 332 | |
| 333 | |
| 334 | def test_dlpack_not_supported(): |
nothing calls this directly
no test coverage detected