Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ where any bugs or reasonable feature requests may be requested anonymously / tre
### Added

**NdArray, XArray and DLPack Feature**:
- `NdArray` n-dimensional dense array (`ndarray` feature) over `Buffer<T>`,
- `NdArray` n-dimensional contiguous array (`ndarray` feature) over `Buffer<T>`,
generic over f32/f64, with NaN null semantics, `NdArrayV` zero-copy views,
transpose and axis permutation, and Table/Matrix/Array interop.
- `SuperNdArray` chunked n-dimensional array with `SuperNdArrayV`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Six typed arrays back standard workloads:
| `IntegerArray<T>` | i8 through u64 |
| `FloatArray<T>` | f32, f64 |
| `StringArray<T>` | UTF-8 with u32 or u64 offsets |
| `BooleanArray` | Bit-packed with validity mask |
| `BooleanArray` | Bit-packed with null mask |
| `CategoricalArray<T>` | Dictionary-encoded |
| `DatetimeArray<T>` | Timestamps, dates, durations |

Expand Down
2 changes: 1 addition & 1 deletion pyo3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Unless you have a very large unique category count, this should not cause perfor

### Nullability

All array types support null values via MinArrow's `MaskedArray` wrapper. The validity bitmap is transferred through the Arrow C Data Interface and PyArrow reconstructs the same null positions on import.
All array types support null values via MinArrow's `MaskedArray` wrapper. The null mask is transferred through the Arrow C Data Interface and PyArrow reconstructs the same null positions on import.

## Conversion Path

Expand Down
2 changes: 1 addition & 1 deletion pyo3/src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
//! ## Nullability
//!
//! All array types support null values via MinArrow's `MaskedArray` wrapper. When an
//! array contains nulls, the validity bitmap is transferred through the Arrow C Data
//! array contains nulls, the null mask is transferred through the Arrow C Data
//! Interface. PyArrow reconstructs the same null positions on import.
//!
//! ## Ownership Model
Expand Down
46 changes: 46 additions & 0 deletions src/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ use std::convert::{From, TryFrom};
use std::sync::Arc;

use crate::enums::error::MinarrowError;
use crate::traits::concatenate::Concatenate;
#[cfg(feature = "views")]
use crate::traits::view::View;
use crate::{
Expand Down Expand Up @@ -1295,6 +1296,51 @@ impl View for BooleanArray<()> {
// From Scalar for Array
// --------------------------------

impl TryFrom<Vec<Array>> for Array {
type Error = MinarrowError;


/// Joins a sequence of arrays end to end.
///
/// The pieces must share an element type, which the join itself
/// enforces. An empty sequence yields the default array.
fn try_from(value: Vec<Array>) -> Result<Self, Self::Error> {
let mut pieces = value.into_iter();
let Some(mut joined) = pieces.next() else {
return Ok(Array::default());
};
for next in pieces {
joined = joined.concat(next)?;
}
Ok(joined)
}
}

#[cfg(feature = "scalar_type")]
impl TryFrom<Array> for Scalar {
type Error = MinarrowError;

/// Reads a single-element array as that element.
///
/// Rejects lengths > 1.
fn try_from(value: Array) -> Result<Self, Self::Error> {
match value.len() {
1 => value.get_scalar(0).ok_or_else(|| MinarrowError::TypeError {
from: "Array",
to: "Scalar",
message: Some("the element could not be read as a scalar".to_owned()),
}),
n => Err(MinarrowError::TypeError {
from: "Array",
to: "Scalar",
message: Some(format!(
"a single value is needed, the array held {n} elements"
)),
}),
}
}
}

#[cfg(feature = "scalar_type")]
impl From<Scalar> for Array {
fn from(scalar: Scalar) -> Self {
Expand Down
Loading
Loading