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

Function test_list_view_slice

python/pyarrow/tests/test_array.py:4517–4533  ·  view source on GitHub ↗
(list_view_type)

Source from the content-addressed store, hash-verified

4515
4516@pytest.mark.parametrize('list_view_type', [pa.ListViewArray, pa.LargeListViewArray])
4517def test_list_view_slice(list_view_type):
4518 # sliced -> values keeps referring to full values buffer, but offsets is
4519 # sliced as well so the offsets correctly point into the full values array
4520 # sliced -> flatten() will return the sliced value array.
4521
4522 array = list_view_type.from_arrays(offsets=[0, 3, 4], sizes=[
4523 3, 1, 2], values=[1, 2, 3, 4, 5, 6])
4524 sliced_array = array[1:]
4525
4526 assert sliced_array.values.to_pylist() == [1, 2, 3, 4, 5, 6]
4527 assert sliced_array.offsets.to_pylist() == [3, 4]
4528 assert sliced_array.flatten().to_pylist() == [4, 5, 6]
4529
4530 i = sliced_array.offsets[0].as_py()
4531 j = sliced_array.offsets[1].as_py()
4532
4533 assert sliced_array[0].as_py() == sliced_array.values[i:j].to_pylist() == [4]
4534
4535
4536@pytest.mark.numpy

Callers

nothing calls this directly

Calls 1

as_pyMethod · 0.80

Tested by

no test coverage detected