pub struct NpyMaskedArray {
pub data: Vec<f64>,
pub mask: Vec<bool>,
pub fill_value: f64,
pub shape: Vec<usize>,
}Expand description
A masked NumPy-style array: elements where mask[i] is true are considered
invalid/missing (following NumPy ma conventions).
Fields§
§data: Vec<f64>Underlying data.
mask: Vec<bool>Per-element mask. true = masked (invalid).
fill_value: f64Fill value used when accessing masked elements.
shape: Vec<usize>Shape of the array.
Implementations§
Source§impl NpyMaskedArray
impl NpyMaskedArray
Sourcepub fn new(
data: Vec<f64>,
mask: Vec<bool>,
shape: Vec<usize>,
fill_value: f64,
) -> Result<Self, String>
pub fn new( data: Vec<f64>, mask: Vec<bool>, shape: Vec<usize>, fill_value: f64, ) -> Result<Self, String>
Create a masked array from data and mask.
Sourcepub fn from_data(data: Vec<f64>, shape: Vec<usize>) -> Result<Self, String>
pub fn from_data(data: Vec<f64>, shape: Vec<usize>) -> Result<Self, String>
Create with all elements unmasked.
Sourcepub fn get_filled(&self, idx: usize) -> f64
pub fn get_filled(&self, idx: usize) -> f64
Get element, returning fill_value if masked.
Sourcepub fn count_valid(&self) -> usize
pub fn count_valid(&self) -> usize
Number of valid (unmasked) elements.
Sourcepub fn mean_valid(&self) -> Option<f64>
pub fn mean_valid(&self) -> Option<f64>
Mean of valid (unmasked) elements. Returns None if all masked.
Sourcepub fn filled(&self) -> Vec<f64>
pub fn filled(&self) -> Vec<f64>
Fill masked values with fill_value and return a plain Vecf64`.
Sourcepub fn mask_greater_than(&mut self, threshold: f64)
pub fn mask_greater_than(&mut self, threshold: f64)
Apply a threshold mask: mask elements where |data\[i\]| > threshold.
Sourcepub fn unmask_all(&mut self)
pub fn unmask_all(&mut self)
Unmask all elements.
Trait Implementations§
Source§impl Clone for NpyMaskedArray
impl Clone for NpyMaskedArray
Source§fn clone(&self) -> NpyMaskedArray
fn clone(&self) -> NpyMaskedArray
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for NpyMaskedArray
impl RefUnwindSafe for NpyMaskedArray
impl Send for NpyMaskedArray
impl Sync for NpyMaskedArray
impl Unpin for NpyMaskedArray
impl UnsafeUnpin for NpyMaskedArray
impl UnwindSafe for NpyMaskedArray
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
Mutably borrows from an owned value. Read more
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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.