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

Function test_variable_list_from_arrays

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

Source from the content-addressed store, hash-verified

1464
1465
1466def test_variable_list_from_arrays():
1467 values = pa.array([1, 2, 3, 4], pa.int64())
1468 offsets = pa.array([0, 2, 4])
1469 result = pa.ListArray.from_arrays(offsets, values)
1470 assert result.to_pylist() == [[1, 2], [3, 4]]
1471 assert result.type.equals(pa.list_(pa.int64()))
1472
1473 offsets = pa.array([0, None, 2, 4])
1474 result = pa.ListArray.from_arrays(offsets, values)
1475 assert result.to_pylist() == [[1, 2], None, [3, 4]]
1476
1477 # raise if offset out of bounds
1478 with pytest.raises(ValueError):
1479 pa.ListArray.from_arrays(pa.array([-1, 2, 4]), values)
1480
1481 with pytest.raises(ValueError):
1482 pa.ListArray.from_arrays(pa.array([0, 2, 5]), values)
1483
1484
1485def test_union_from_dense():

Callers

nothing calls this directly

Calls 2

equalsMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected