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

Function test_union_array_slice

python/pyarrow/tests/test_array.py:1685–1701  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1683
1684
1685def test_union_array_slice():
1686 # ARROW-2314
1687 arr = pa.UnionArray.from_sparse(pa.array([0, 0, 1, 1], type=pa.int8()),
1688 [pa.array(["a", "b", "c", "d"]),
1689 pa.array([1, 2, 3, 4])])
1690 assert arr[1:].to_pylist() == ["b", 3, 4]
1691
1692 binary = pa.array([b'a', b'b', b'c', b'd'], type='binary')
1693 int64 = pa.array([1, 2, 3], type='int64')
1694 types = pa.array([0, 1, 0, 0, 1, 1, 0], type='int8')
1695 value_offsets = pa.array([0, 0, 2, 1, 1, 2, 3], type='int32')
1696
1697 arr = pa.UnionArray.from_dense(types, value_offsets, [binary, int64])
1698 lst = arr.to_pylist()
1699 for i in range(len(arr)):
1700 for j in range(i, len(arr)):
1701 assert arr[i:j].to_pylist() == lst[i:j]
1702
1703
1704def _check_cast_case(case, *, safe=True, check_array_construction=True):

Callers

nothing calls this directly

Calls 2

lenFunction · 0.85
arrayMethod · 0.45

Tested by

no test coverage detected