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

Function test_auto_chunking_binary_like

python/pyarrow/tests/test_convert_builtin.py:2334–2372  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2332
2333@pytest.mark.large_memory
2334def test_auto_chunking_binary_like():
2335 # single chunk
2336 v1 = b'x' * 100000000
2337 v2 = b'x' * 147483646
2338
2339 # single chunk
2340 one_chunk_data = [v1] * 20 + [b'', None, v2]
2341 arr = pa.array(one_chunk_data, type=pa.binary())
2342 assert isinstance(arr, pa.Array)
2343 assert len(arr) == 23
2344 assert arr[20].as_py() == b''
2345 assert arr[21].as_py() is None
2346 assert arr[22].as_py() == v2
2347
2348 # two chunks
2349 two_chunk_data = one_chunk_data + [b'two']
2350 arr = pa.array(two_chunk_data, type=pa.binary())
2351 assert isinstance(arr, pa.ChunkedArray)
2352 assert arr.num_chunks == 2
2353 assert len(arr.chunk(0)) == 23
2354 assert len(arr.chunk(1)) == 1
2355 assert arr.chunk(0)[20].as_py() == b''
2356 assert arr.chunk(0)[21].as_py() is None
2357 assert arr.chunk(0)[22].as_py() == v2
2358 assert arr.chunk(1).to_pylist() == [b'two']
2359
2360 # three chunks
2361 three_chunk_data = one_chunk_data * 2 + [b'three', b'three']
2362 arr = pa.array(three_chunk_data, type=pa.binary())
2363 assert isinstance(arr, pa.ChunkedArray)
2364 assert arr.num_chunks == 3
2365 assert len(arr.chunk(0)) == 23
2366 assert len(arr.chunk(1)) == 23
2367 assert len(arr.chunk(2)) == 2
2368 for i in range(2):
2369 assert arr.chunk(i)[20].as_py() == b''
2370 assert arr.chunk(i)[21].as_py() is None
2371 assert arr.chunk(i)[22].as_py() == v2
2372 assert arr.chunk(2).to_pylist() == [b'three', b'three']
2373
2374
2375@pytest.mark.large_memory

Callers

nothing calls this directly

Calls 3

lenFunction · 0.85
as_pyMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected