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

Function test_buffer_from_numpy

python/pyarrow/tests/test_io.py:486–500  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

484
485@pytest.mark.numpy
486def test_buffer_from_numpy():
487 # C-contiguous
488 arr = np.arange(12, dtype=np.int8).reshape((3, 4))
489 buf = pa.py_buffer(arr)
490 assert buf.is_cpu
491 assert buf.is_mutable
492 assert buf.to_pybytes() == arr.tobytes()
493 # F-contiguous; note strides information is lost
494 buf = pa.py_buffer(arr.T)
495 assert buf.is_cpu
496 assert buf.is_mutable
497 assert buf.to_pybytes() == arr.tobytes()
498 # Non-contiguous
499 with pytest.raises(ValueError, match="not contiguous"):
500 buf = pa.py_buffer(arr.T[::2])
501
502
503@pytest.mark.numpy

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected