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

Function test_list_array_flatten

python/pyarrow/tests/test_array.py:3296–3348  ·  view source on GitHub ↗
(offset_type, list_type_factory)

Source from the content-addressed store, hash-verified

3294@pytest.mark.parametrize(('offset_type', 'list_type_factory'),
3295 [(pa.int32(), pa.list_), (pa.int64(), pa.large_list)])
3296def test_list_array_flatten(offset_type, list_type_factory):
3297 typ2 = list_type_factory(
3298 list_type_factory(
3299 pa.int64()
3300 )
3301 )
3302 arr2 = pa.array([
3303 None,
3304 [
3305 [1, None, 2],
3306 None,
3307 [3, 4]
3308 ],
3309 [],
3310 [
3311 [],
3312 [5, 6],
3313 None
3314 ],
3315 [
3316 [7, 8]
3317 ]
3318 ], type=typ2)
3319 offsets2 = pa.array([0, 0, 3, 3, 6, 7], type=offset_type)
3320
3321 typ1 = list_type_factory(pa.int64())
3322 arr1 = pa.array([
3323 [1, None, 2],
3324 None,
3325 [3, 4],
3326 [],
3327 [5, 6],
3328 None,
3329 [7, 8]
3330 ], type=typ1)
3331 offsets1 = pa.array([0, 3, 3, 5, 5, 7, 7, 9], type=offset_type)
3332
3333 arr0 = pa.array([
3334 1, None, 2,
3335 3, 4,
3336 5, 6,
3337 7, 8
3338 ], type=pa.int64())
3339
3340 assert arr2.flatten().equals(arr1)
3341 assert arr2.offsets.equals(offsets2)
3342 assert arr2.values.equals(arr1)
3343 assert arr1.flatten().equals(arr0)
3344 assert arr1.offsets.equals(offsets1)
3345 assert arr1.values.equals(arr0)
3346 assert arr2.flatten().flatten().equals(arr0)
3347 assert arr2.values.values.equals(arr0)
3348 assert arr2.flatten(True).equals(arr0)
3349
3350
3351@pytest.mark.parametrize('list_type', [

Callers

nothing calls this directly

Calls 2

equalsMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected