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

Function test_list_slice_output_fixed

python/pyarrow/tests/test_compute.py:4325–4344  ·  view source on GitHub ↗
(start, stop, step, expected, value_type,
                                 list_type)

Source from the content-addressed store, hash-verified

4323@pytest.mark.parametrize("value_type", (pa.string, pa.int16, pa.float64))
4324@pytest.mark.parametrize("list_type", (pa.list_, pa.large_list, "fixed"))
4325def 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", (

Callers

nothing calls this directly

Calls 3

list_typeFunction · 0.85
castMethod · 0.45
arrayMethod · 0.45

Tested by

no test coverage detected