pub trait ReadNpyExt: Sized {
// Required method
fn read_npy<R: Read>(reader: R) -> Result<Self, ReadNpyError>;
}
Expand description
Extension trait for reading Array
from .npy
files.
§Example
use ndarray::Array2;
use ndarray_npy::ReadNpyExt;
use std::fs::File;
let reader = File::open("resources/array.npy")?;
let arr = Array2::<i32>::read_npy(reader)?;
Required Methods§
Sourcefn read_npy<R: Read>(reader: R) -> Result<Self, ReadNpyError>
fn read_npy<R: Read>(reader: R) -> Result<Self, ReadNpyError>
Reads the array from reader
in .npy
format.
This function is the Rust equivalent of
numpy.load
for .npy
files.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.