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

Function test_chunked_array_flatten

python/pyarrow/tests/test_table.py:465–480  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

463
464
465def test_chunked_array_flatten():
466 ty = pa.struct([pa.field('x', pa.int16()),
467 pa.field('y', pa.float32())])
468 a = pa.array([(1, 2.5), (3, 4.5), (5, 6.5)], type=ty)
469 carr = pa.chunked_array(a)
470 x, y = carr.flatten()
471 assert x.equals(pa.chunked_array(pa.array([1, 3, 5], type=pa.int16())))
472 assert y.equals(pa.chunked_array(pa.array([2.5, 4.5, 6.5],
473 type=pa.float32())))
474
475 # Empty column
476 a = pa.array([], type=ty)
477 carr = pa.chunked_array(a)
478 x, y = carr.flatten()
479 assert x.equals(pa.chunked_array(pa.array([], type=pa.int16())))
480 assert y.equals(pa.chunked_array(pa.array([], type=pa.float32())))
481
482
483def test_chunked_array_unify_dictionaries():

Callers

nothing calls this directly

Calls 4

chunked_arrayMethod · 0.80
equalsMethod · 0.80
fieldMethod · 0.45
arrayMethod · 0.45

Tested by

no test coverage detected