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

Function test_chunked_array_construction

python/pyarrow/tests/test_table.py:67–109  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65
66
67def test_chunked_array_construction():
68 arr = pa.chunked_array([
69 [1, 2, 3],
70 [4, 5, 6],
71 [7, 8, 9],
72 ])
73 assert arr.type == pa.int64()
74 assert len(arr) == 9
75 assert len(arr.chunks) == 3
76
77 arr = pa.chunked_array([
78 [1, 2, 3],
79 [4., 5., 6.],
80 [7, 8, 9],
81 ])
82 assert arr.type == pa.int64()
83 assert len(arr) == 9
84 assert len(arr.chunks) == 3
85
86 arr = pa.chunked_array([
87 [1, 2, 3],
88 [4., 5., 6.],
89 [7, 8, 9],
90 ], type=pa.int8())
91 assert arr.type == pa.int8()
92 assert len(arr) == 9
93 assert len(arr.chunks) == 3
94
95 arr = pa.chunked_array([
96 [1, 2, 3],
97 []
98 ])
99 assert arr.type == pa.int64()
100 assert len(arr) == 3
101 assert len(arr.chunks) == 2
102
103 msg = "cannot construct ChunkedArray from empty vector and omitted type"
104 with pytest.raises(ValueError, match=msg):
105 assert pa.chunked_array([])
106
107 assert pa.chunked_array([], type=pa.string()).type == pa.string()
108 assert pa.chunked_array([[]]).type == pa.null()
109 assert pa.chunked_array([[]], type=pa.string()).type == pa.string()
110
111
112def test_combine_chunks():

Callers

nothing calls this directly

Calls 3

lenFunction · 0.85
chunked_arrayMethod · 0.80
stringMethod · 0.45

Tested by

no test coverage detected