| 4323 | @pytest.mark.parametrize("value_type", (pa.string, pa.int16, pa.float64)) |
| 4324 | @pytest.mark.parametrize("list_type", (pa.list_, pa.large_list, "fixed")) |
| 4325 | def test_list_slice_output_fixed(start, stop, step, expected, value_type, |
| 4326 | list_type): |
| 4327 | if list_type == "fixed": |
| 4328 | arr = pa.array([[1, 2, 3], [4, 5, None], [6, None, None], None], |
| 4329 | pa.list_(pa.int8(), 3)).cast(pa.list_(value_type(), 3)) |
| 4330 | else: |
| 4331 | arr = pa.array([[1, 2, 3], [4, 5], [6], None], |
| 4332 | pa.list_(pa.int8())).cast(list_type(value_type())) |
| 4333 | |
| 4334 | args = arr, start, stop, step, True |
| 4335 | if stop is None and list_type != "fixed": |
| 4336 | msg = ("Unable to produce FixedSizeListArray from " |
| 4337 | "non-FixedSizeListArray without `stop` being set.") |
| 4338 | with pytest.raises(pa.ArrowInvalid, match=msg): |
| 4339 | pc.list_slice(*args) |
| 4340 | else: |
| 4341 | result = pc.list_slice(*args) |
| 4342 | pylist = result.cast(pa.list_(pa.int8(), |
| 4343 | result.type.list_size)).to_pylist() |
| 4344 | assert pylist == [e[::step] if e else e for e in expected] |
| 4345 | |
| 4346 | |
| 4347 | @pytest.mark.parametrize("start,stop", ( |