1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! # ferrum-numpy-interop
//!
//! A companion crate providing zero-copy (where possible) conversions between
//! ferrum arrays and external array ecosystems:
//!
//! - **NumPy** (via PyO3) — feature `"python"`
//! - **Apache Arrow** — feature `"arrow"`
//! - **Polars** — feature `"polars"`
//!
//! All three backends are feature-gated and disabled by default. Enable them
//! in your `Cargo.toml`:
//!
//! ```toml
//! [dependencies.ferrum-numpy-interop]
//! version = "0.1"
//! features = ["arrow"] # or "python", "polars"
//! ```
//!
//! ## Design principles
//!
//! 1. **Safety first** — every conversion validates dtypes and memory layout
//! before returning. No silent reinterpretation of memory.
//! 2. **Zero-copy when possible** — C-contiguous arrays are shared without
//! copying where the target format supports it.
//! 3. **Explicit errors** — dtype mismatches, null values, and unsupported
//! types produce clear [`FerrumError`](ferrum_core::FerrumError) messages.
// Re-export the main conversion traits at crate root for ergonomics.
pub use ;
pub use ;
pub use ;