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: AThe 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 value_2(&self, fillvalue: Option<A>) -> Array<A, D>
pub fn value_2(&self, fillvalue: 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 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, othermask: &Array<bool, D>) -> Result<Self, ArrayError>
pub fn mask_or(&self, othermask: &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, othermask: &Array<bool, D>) -> Result<Self, ArrayError>
pub fn mask_and(&self, othermask: &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
Returns None if there are no unmasked elements or if count conversion fails.
Sourcepub fn var(&self, ddof: usize) -> Option<A>
pub fn var(&self, ddof: usize) -> Option<A>
Compute the variance of all unmasked elements
Returns None if there are insufficient unmasked elements or if count conversion fails.
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§fn clone_from(&mut self, source: &Self)
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
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.Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.