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

Function test_sequence_nesting_levels

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

Source from the content-addressed store, hash-verified

1602
1603
1604def test_sequence_nesting_levels():
1605 data = [1, 2, None]
1606 arr = pa.array(data)
1607 assert arr.type == pa.int64()
1608 assert arr.to_pylist() == data
1609
1610 data = [[1], [2], None]
1611 arr = pa.array(data)
1612 assert arr.type == pa.list_(pa.int64())
1613 assert arr.to_pylist() == data
1614
1615 data = [[1], [2, 3, 4], [None]]
1616 arr = pa.array(data)
1617 assert arr.type == pa.list_(pa.int64())
1618 assert arr.to_pylist() == data
1619
1620 data = [None, [[None, 1]], [[2, 3, 4], None], [None]]
1621 arr = pa.array(data)
1622 assert arr.type == pa.list_(pa.list_(pa.int64()))
1623 assert arr.to_pylist() == data
1624
1625 exceptions = (pa.ArrowInvalid, pa.ArrowTypeError)
1626
1627 # Mixed nesting levels are rejected
1628 with pytest.raises(exceptions):
1629 pa.array([1, 2, [1]])
1630
1631 with pytest.raises(exceptions):
1632 pa.array([1, 2, []])
1633
1634 with pytest.raises(exceptions):
1635 pa.array([[1], [2], [None, [1]]])
1636
1637
1638def test_sequence_mixed_types_fails():

Callers

nothing calls this directly

Calls 1

arrayMethod · 0.45

Tested by

no test coverage detected