-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
«ratal»
committed
Mar 6, 2024
1 parent
14caa2e
commit ab2415a
Showing
5 changed files
with
25 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
//! Module to export mdf files to other file formats. | ||
pub mod numpy; | ||
pub mod python_arrow_helpers; | ||
//pub mod parquet; | ||
pub mod polars; | ||
// pub mod tensor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//! helpers for arrow use with python | ||
use std::sync::Arc; | ||
|
||
use arrow::array::{make_array, Array, ArrayData}; | ||
use arrow::pyarrow::PyArrowType; | ||
use pyo3::prelude::*; | ||
use pyo3::PyResult; | ||
|
||
/// Take an arrow array from python and convert it to a rust arrow array. | ||
/// This operation does not copy data. | ||
#[allow(dead_code)] | ||
pub fn array_to_rust(arrow_array: PyArrowType<ArrayData>) -> PyResult<Arc<dyn Array>> { | ||
// prepare a pointer to receive the Array struct | ||
let array = arrow_array.0; // Extract from PyArrowType wrapper | ||
Ok(make_array(array)) | ||
} | ||
|
||
/// Arrow array to Python. | ||
pub(crate) fn to_py_array(_: Python, array: Arc<dyn Array>) -> PyResult<PyArrowType<ArrayData>> { | ||
Ok(PyArrowType(array.into_data())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters