| 848 | @pytest.mark.parametrize('list_type_factory', [ |
| 849 | pa.list_, pa.large_list, pa.list_view, pa.large_list_view]) |
| 850 | def test_list_from_buffers(list_type_factory): |
| 851 | ty = list_type_factory(pa.int16()) |
| 852 | array = pa.array([[0, 1, 2], None, [], [3, 4, 5]], type=ty) |
| 853 | assert array.type == ty |
| 854 | |
| 855 | buffers = array.buffers() |
| 856 | |
| 857 | with pytest.raises(ValueError): |
| 858 | # No children |
| 859 | pa.Array.from_buffers(ty, 4, buffers[:ty.num_buffers]) |
| 860 | |
| 861 | child = pa.Array.from_buffers(pa.int16(), 6, buffers[ty.num_buffers:]) |
| 862 | copied = pa.Array.from_buffers(ty, 4, buffers[:ty.num_buffers], children=[child]) |
| 863 | assert copied.equals(array) |
| 864 | |
| 865 | with pytest.raises(ValueError): |
| 866 | # too many children |
| 867 | pa.Array.from_buffers(ty, 4, buffers[:ty.num_buffers], |
| 868 | children=[child, child]) |
| 869 | |
| 870 | |
| 871 | def test_struct_from_buffers(): |