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

Function test_to_numpy_zero_copy

python/pyarrow/tests/test_array.py:180–196  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

178
179@pytest.mark.numpy
180def test_to_numpy_zero_copy():
181 arr = pa.array(range(10))
182
183 np_arr = arr.to_numpy()
184
185 # check for zero copy (both arrays using same memory)
186 arrow_buf = arr.buffers()[1]
187 assert arrow_buf.address == np_arr.ctypes.data
188
189 arr = None
190 import gc
191 gc.collect()
192
193 # Ensure base is still valid
194 assert np_arr.base is not None
195 expected = np.arange(10)
196 np.testing.assert_array_equal(np_arr, expected)
197
198
199@pytest.mark.numpy

Callers

nothing calls this directly

Calls 2

buffersMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected