Struct ndarray_npz::NpzReader
source · pub struct NpzReader<R: Read + Seek> { /* private fields */ }
Expand description
Reader for .npz
files.
Example
use ndarray_npz::{
ndarray::{Array1, Array2},
NpzReader,
};
use std::fs::File;
let mut npz = NpzReader::new(File::open("arrays.npz")?)?;
let a: Array2<i32> = npz.by_name("a")?;
let b: Array1<i32> = npz.by_name("b")?;
Implementations§
source§impl<R: Read + Seek> NpzReader<R>
impl<R: Read + Seek> NpzReader<R>
sourcepub fn new(reader: R) -> Result<NpzReader<R>, ReadNpzError>
pub fn new(reader: R) -> Result<NpzReader<R>, ReadNpzError>
sourcepub fn by_name<S, D>(
&mut self,
name: &str
) -> Result<ArrayBase<S, D>, ReadNpzError>where
S::Elem: ReadableElement,
S: DataOwned,
D: Dimension,
pub fn by_name<S, D>( &mut self, name: &str ) -> Result<ArrayBase<S, D>, ReadNpzError>where S::Elem: ReadableElement, S: DataOwned, D: Dimension,
Reads an array by name.
Errors
Reading an array from an archive can fail with ReadNpyError
or ZipError
.
sourcepub fn by_index<S, D>(
&mut self,
index: usize
) -> Result<ArrayBase<S, D>, ReadNpzError>where
S::Elem: ReadableElement,
S: DataOwned,
D: Dimension,
pub fn by_index<S, D>( &mut self, index: usize ) -> Result<ArrayBase<S, D>, ReadNpzError>where S::Elem: ReadableElement, S: DataOwned, D: Dimension,
Reads an array by index in the .npz
file.
Errors
Reading an array from an archive can fail with ReadNpyError
or ZipError
.