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

Function test_struct_from_buffers

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

Source from the content-addressed store, hash-verified

869
870
871def test_struct_from_buffers():
872 ty = pa.struct([pa.field('a', pa.int16()), pa.field('b', pa.utf8())])
873 array = pa.array([{'a': 0, 'b': 'foo'}, None, {'a': 5, 'b': ''}],
874 type=ty)
875 buffers = array.buffers()
876
877 with pytest.raises(ValueError):
878 # No children
879 pa.Array.from_buffers(ty, 3, [None, buffers[1]])
880
881 children = [pa.Array.from_buffers(pa.int16(), 3, buffers[1:3]),
882 pa.Array.from_buffers(pa.utf8(), 3, buffers[3:])]
883 copied = pa.Array.from_buffers(ty, 3, buffers[:1], children=children)
884 assert copied.equals(array)
885
886 with pytest.raises(ValueError):
887 # not enough many children
888 pa.Array.from_buffers(ty, 3, [buffers[0]],
889 children=children[:1])
890
891
892def test_struct_from_arrays():

Callers

nothing calls this directly

Calls 4

buffersMethod · 0.80
equalsMethod · 0.80
fieldMethod · 0.45
arrayMethod · 0.45

Tested by

no test coverage detected