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

Function test_from_dlpack_zero_copy

python/pyarrow/tests/test_dlpack.py:470–479  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

468@requires_numpy_version("2.1.0")
469@check_bytes_allocated
470def test_from_dlpack_zero_copy():
471 expected = np.array([1, 2, 3], dtype=np.int64)
472 tensor = pa.Tensor.from_dlpack(expected)
473 result = tensor.to_numpy()
474 # Zero-copy import: mutating the source is visible through the tensor.
475 expected[0] = 100
476 assert result[0] == 100
477 # Same for mutating the result
478 result[1] = 42
479 assert expected[1] == 42
480
481
482@requires_numpy_version("2.1.0")

Callers

nothing calls this directly

Calls 1

arrayMethod · 0.45

Tested by

no test coverage detected