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

Function test_chunked_array_construction

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

Source from the content-addressed store, hash-verified

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