| 1464 | |
| 1465 | |
| 1466 | def 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 | |
| 1485 | def test_union_from_dense(): |