pub struct MaskedArray<A, S, D>{
pub data: ArrayBase<S, D>,
pub mask: Array<bool, D>,
pub fill_value: A,
}
Expand description
Represents an array with a mask to identify invalid or missing values
Fields§
§data: ArrayBase<S, D>
The underlying data array
mask: Array<bool, D>
The mask array: true = masked (invalid), false = valid
fill_value: A
The fill value used when creating a filled array
Implementations§
Source§impl<A, S, D> MaskedArray<A, S, D>
impl<A, S, D> MaskedArray<A, S, D>
Sourcepub fn new(
data: ArrayBase<S, D>,
mask: Option<Array<bool, D>>,
fill_value: Option<A>,
) -> Result<Self, ArrayError>
pub fn new( data: ArrayBase<S, D>, mask: Option<Array<bool, D>>, fill_value: Option<A>, ) -> Result<Self, ArrayError>
Create a new MaskedArray
from data and mask
§Errors
Returns ArrayError::ShapeMismatch
if the mask shape doesn’t match the data shape.
Sourcepub fn filled(&self, fill_value: Option<A>) -> Array<A, D>
pub fn filled(&self, fill_value: Option<A>) -> Array<A, D>
Get a view of the data with masked values replaced by fill_value
Sourcepub fn has_masked(&self) -> bool
pub fn has_masked(&self) -> bool
Returns true if the array has at least one masked element
Sourcepub fn set_mask(&mut self, mask: Array<bool, D>) -> Result<(), ArrayError>
pub fn set_mask(&mut self, mask: Array<bool, D>) -> Result<(), ArrayError>
Set a new mask for the array
§Errors
Returns ArrayError::ShapeMismatch
if the mask shape doesn’t match the data shape.
Sourcepub fn set_fill_value(&mut self, fill_value: A)
pub fn set_fill_value(&mut self, fill_value: A)
Set the fill value for the array
Sourcepub fn compressed(&self) -> Array<A, Ix1>
pub fn compressed(&self) -> Array<A, Ix1>
Returns a new array containing only unmasked values
Sourcepub const fn data_and_mask(&self) -> (&ArrayBase<S, D>, &Array<bool, D>)
pub const fn data_and_mask(&self) -> (&ArrayBase<S, D>, &Array<bool, D>)
Returns a tuple of (data, mask)
Sourcepub fn mask_op<F>(&self, op: F) -> Self
pub fn mask_op<F>(&self, op: F) -> Self
Creates a new masked array with the given mask operation applied
Sourcepub fn harden_mask(&self) -> Self
pub fn harden_mask(&self) -> Self
Creates a new masked array with a hardened mask (copy)
Sourcepub fn soften_mask(&self) -> Self
pub fn soften_mask(&self) -> Self
Create a new masked array with a softened mask (copy)
Sourcepub fn mask_where<F>(&self, condition: F) -> Self
pub fn mask_where<F>(&self, condition: F) -> Self
Create a new masked array where the result of applying the function to each element is masked
Sourcepub fn mask_or(&self, other_mask: &Array<bool, D>) -> Result<Self, ArrayError>
pub fn mask_or(&self, other_mask: &Array<bool, D>) -> Result<Self, ArrayError>
Create a logical OR of the mask with another mask
§Errors
Returns ArrayError::ShapeMismatch
if the mask shapes don’t match.
Sourcepub fn mask_and(&self, other_mask: &Array<bool, D>) -> Result<Self, ArrayError>
pub fn mask_and(&self, other_mask: &Array<bool, D>) -> Result<Self, ArrayError>
Create a logical AND of the mask with another mask
§Errors
Returns ArrayError::ShapeMismatch
if the mask shapes don’t match.
Sourcepub fn reshape<E>(
&self,
shape: E,
) -> Result<MaskedArray<A, OwnedRepr<A>, E>, ArrayError>
pub fn reshape<E>( &self, shape: E, ) -> Result<MaskedArray<A, OwnedRepr<A>, E>, ArrayError>
Source§impl<A, S, D> MaskedArray<A, S, D>where
A: Clone + PartialEq + NumAssign + Zero + One + PartialOrd,
S: Data<Elem = A> + Clone + RawDataClone,
D: Dimension,
Implementation of statistical methods
impl<A, S, D> MaskedArray<A, S, D>where
A: Clone + PartialEq + NumAssign + Zero + One + PartialOrd,
S: Data<Elem = A> + Clone + RawDataClone,
D: Dimension,
Implementation of statistical methods
Source§impl<A, S, D> MaskedArray<A, S, D>
Implementation of statistical methods for floating point types
impl<A, S, D> MaskedArray<A, S, D>
Implementation of statistical methods for floating point types
Sourcepub fn mean(&self) -> Option<A>
pub fn mean(&self) -> Option<A>
Compute the mean of all unmasked elements
§Panics
Panics if the count cannot be converted to type A.
Sourcepub fn var(&self, ddof: usize) -> Option<A>
pub fn var(&self, ddof: usize) -> Option<A>
Compute the variance of all unmasked elements
§Panics
Panics if the count cannot be converted to type A.
Sourcepub fn std(&self, ddof: usize) -> Option<A>
pub fn std(&self, ddof: usize) -> Option<A>
Compute the standard deviation of all unmasked elements
Sourcepub fn all_finite(&self) -> bool
pub fn all_finite(&self) -> bool
Check if all unmasked elements are finite
Trait Implementations§
Source§impl<A, S1, S2, D> Add<&MaskedArray<A, S2, D>> for &MaskedArray<A, S1, D>where
A: Clone + Add<Output = A> + PartialEq,
S1: Data<Elem = A> + Clone + RawDataClone,
S2: Data<Elem = A> + Clone + RawDataClone,
D: Dimension,
impl<A, S1, S2, D> Add<&MaskedArray<A, S2, D>> for &MaskedArray<A, S1, D>where
A: Clone + Add<Output = A> + PartialEq,
S1: Data<Elem = A> + Clone + RawDataClone,
S2: Data<Elem = A> + Clone + RawDataClone,
D: Dimension,
Source§impl<A, S, D> Clone for MaskedArray<A, S, D>
impl<A, S, D> Clone for MaskedArray<A, S, D>
Source§fn clone(&self) -> MaskedArray<A, S, D>
fn clone(&self) -> MaskedArray<A, S, D>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<A, S, D> Debug for MaskedArray<A, S, D>
Implementation of Debug for MaskedArray
impl<A, S, D> Debug for MaskedArray<A, S, D>
Implementation of Debug for MaskedArray
Source§impl<A, S, D> Display for MaskedArray<A, S, D>
Implementation of Display for MaskedArray
impl<A, S, D> Display for MaskedArray<A, S, D>
Implementation of Display for MaskedArray
Source§impl<A, S1, S2, D> Div<&MaskedArray<A, S2, D>> for &MaskedArray<A, S1, D>
impl<A, S1, S2, D> Div<&MaskedArray<A, S2, D>> for &MaskedArray<A, S1, D>
Source§impl<A, S1, S2, D> Mul<&MaskedArray<A, S2, D>> for &MaskedArray<A, S1, D>where
A: Clone + Mul<Output = A> + PartialEq,
S1: Data<Elem = A> + Clone + RawDataClone,
S2: Data<Elem = A> + Clone + RawDataClone,
D: Dimension,
impl<A, S1, S2, D> Mul<&MaskedArray<A, S2, D>> for &MaskedArray<A, S1, D>where
A: Clone + Mul<Output = A> + PartialEq,
S1: Data<Elem = A> + Clone + RawDataClone,
S2: Data<Elem = A> + Clone + RawDataClone,
D: Dimension,
Source§impl<A, S1, S2, D> Sub<&MaskedArray<A, S2, D>> for &MaskedArray<A, S1, D>where
A: Clone + Sub<Output = A> + PartialEq,
S1: Data<Elem = A> + Clone + RawDataClone,
S2: Data<Elem = A> + Clone + RawDataClone,
D: Dimension,
impl<A, S1, S2, D> Sub<&MaskedArray<A, S2, D>> for &MaskedArray<A, S1, D>where
A: Clone + Sub<Output = A> + PartialEq,
S1: Data<Elem = A> + Clone + RawDataClone,
S2: Data<Elem = A> + Clone + RawDataClone,
D: Dimension,
Auto Trait Implementations§
impl<A, S, D> Freeze for MaskedArray<A, S, D>
impl<A, S, D> RefUnwindSafe for MaskedArray<A, S, D>
impl<A, S, D> Send for MaskedArray<A, S, D>
impl<A, S, D> Sync for MaskedArray<A, S, D>
impl<A, S, D> Unpin for MaskedArray<A, S, D>
impl<A, S, D> UnwindSafe for MaskedArray<A, S, D>
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more