@@ -7,7 +7,7 @@ use arrow::array::{Array as ArrowArray, ArrayRef};
77use arrow:: pyarrow:: ToPyArrow ;
88use pyo3:: exceptions:: PyValueError ;
99use pyo3:: prelude:: * ;
10- use pyo3:: types:: { IntoPyDict , PyList } ;
10+ use pyo3:: types:: { PyDict , PyList } ;
1111use pyo3:: PyClass ;
1212use vortex:: array:: ChunkedArray ;
1313use vortex:: arrow:: { infer_data_type, IntoArrowArray } ;
@@ -29,7 +29,7 @@ use crate::python_repr::PythonRepr;
2929use crate :: scalar:: PyScalar ;
3030
3131pub ( crate ) fn init ( py : Python , parent : & Bound < PyModule > ) -> PyResult < ( ) > {
32- let m = PyModule :: new_bound ( py, "arrays" ) ?;
32+ let m = PyModule :: new ( py, "arrays" ) ?;
3333 parent. add_submodule ( & m) ?;
3434 install_module ( "vortex._lib.arrays" , & m) ?;
3535
@@ -250,24 +250,28 @@ impl PyArray {
250250 // the preferred type of each chunk may be different.
251251 let arrow_dtype = infer_data_type ( chunked_array. dtype ( ) ) ?;
252252
253- let chunks: Vec < ArrayRef > = chunked_array
253+ let chunks = chunked_array
254254 . chunks ( )
255- . map ( |chunk| -> PyResult < ArrayRef > { Ok ( chunk. into_arrow ( & arrow_dtype) ?) } )
255+ . map ( |chunk| PyResult :: Ok ( chunk. into_arrow ( & arrow_dtype) ?) )
256256 . collect :: < PyResult < Vec < ArrayRef > > > ( ) ?;
257257 if chunks. is_empty ( ) {
258258 return Err ( PyValueError :: new_err ( "No chunks in array" ) ) ;
259259 }
260+
260261 let pa_data_type = chunks[ 0 ] . data_type ( ) . clone ( ) . to_pyarrow ( py) ?;
261- let chunks: PyResult < Vec < PyObject > > = chunks
262+ let chunks = chunks
262263 . iter ( )
263264 . map ( |arrow_array| arrow_array. into_data ( ) . to_pyarrow ( py) )
264- . collect ( ) ;
265+ . collect :: < Result < Vec < _ > , _ > > ( ) ?;
266+
267+ let kwargs =
268+ PyDict :: from_sequence ( & PyList :: new ( py, vec ! [ ( "type" , pa_data_type) ] ) ?. into_any ( ) ) ?;
265269
266270 // Combine into a chunked array
267- PyModule :: import_bound ( py, "pyarrow" ) ?. call_method (
271+ PyModule :: import ( py, "pyarrow" ) ?. call_method (
268272 "chunked_array" ,
269- ( PyList :: new_bound ( py, chunks? ) , ) ,
270- Some ( & [ ( "type" , pa_data_type ) ] . into_py_dict_bound ( py ) ) ,
273+ ( PyList :: new ( py, chunks) ? , ) ,
274+ Some ( & kwargs ) ,
271275 )
272276 } else {
273277 Ok ( vortex
0 commit comments