| 4515 | |
| 4516 | @pytest.mark.parametrize('list_view_type', [pa.ListViewArray, pa.LargeListViewArray]) |
| 4517 | def 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 |