pub struct NpzArchive {
pub arrays: Vec<(String, NpyArray)>,
}Expand description
A higher-level NPZ archive that stores typed NpyArray objects by name.
Unlike NpzWriter, this type stores fully parsed NpyArray values and
supports reading them back without specifying the dtype at call time.
Fields§
§arrays: Vec<(String, NpyArray)>Named arrays stored in the archive.
Implementations§
Source§impl NpzArchive
impl NpzArchive
Sourcepub fn get(&self, name: &str) -> Option<&NpyArray>
pub fn get(&self, name: &str) -> Option<&NpyArray>
Retrieve a reference to the array with the given name.
Sourcepub fn remove(&mut self, name: &str) -> bool
pub fn remove(&mut self, name: &str) -> bool
Remove an array by name; returns true if it was present.
Sourcepub fn to_bytes(&self) -> Result<Vec<u8>, String>
pub fn to_bytes(&self) -> Result<Vec<u8>, String>
Serialize to the NPZ container format (compatible with NpzWriter).
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self, String>
pub fn from_bytes(data: &[u8]) -> Result<Self, String>
Deserialize from NPZ container bytes.
Source§impl NpzArchive
impl NpzArchive
Sourcepub fn add_array(&mut self, name: &str, array: NpyArray)
pub fn add_array(&mut self, name: &str, array: NpyArray)
Add a pre-built NpyArray under name, replacing any existing entry
with that name.
Sourcepub fn load_all(data: &[u8]) -> Result<Self, String>
pub fn load_all(data: &[u8]) -> Result<Self, String>
Load all arrays from raw NPZ bytes and return them as a new archive.
This is an alias for NpzArchive::from_bytes with a more descriptive
name to match the “load_all” specification.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &NpyArray)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &NpyArray)>
Return an iterator over (name, &NpyArray) pairs.
Sourcepub fn merge(&mut self, other: NpzArchive)
pub fn merge(&mut self, other: NpzArchive)
Merge another archive into self, overwriting duplicate names.
Sourcepub fn total_elements(&self) -> usize
pub fn total_elements(&self) -> usize
Return the total number of elements across all stored arrays.
Trait Implementations§
Source§impl Clone for NpzArchive
impl Clone for NpzArchive
Source§fn clone(&self) -> NpzArchive
fn clone(&self) -> NpzArchive
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NpzArchive
impl Debug for NpzArchive
Source§impl Default for NpzArchive
impl Default for NpzArchive
Source§fn default() -> NpzArchive
fn default() -> NpzArchive
Auto Trait Implementations§
impl Freeze for NpzArchive
impl RefUnwindSafe for NpzArchive
impl Send for NpzArchive
impl Sync for NpzArchive
impl Unpin for NpzArchive
impl UnsafeUnpin for NpzArchive
impl UnwindSafe for NpzArchive
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.