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

Function test_to_numpy_writable

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

Source from the content-addressed store, hash-verified

241
242@pytest.mark.numpy
243def test_to_numpy_writable():
244 arr = pa.array(range(10))
245 np_arr = arr.to_numpy()
246
247 # by default not writable for zero-copy conversion
248 with pytest.raises(ValueError):
249 np_arr[0] = 10
250
251 np_arr2 = arr.to_numpy(zero_copy_only=False, writable=True)
252 np_arr2[0] = 10
253 assert arr[0].as_py() == 0
254
255 # when asking for writable, cannot do zero-copy
256 with pytest.raises(ValueError):
257 arr.to_numpy(zero_copy_only=True, writable=True)
258
259
260@pytest.mark.numpy

Callers

nothing calls this directly

Calls 2

as_pyMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected