Skip to main content

MaskedArray

Struct MaskedArray 

Source
pub struct MaskedArray<T: Element, D: Dimension> { /* private fields */ }
Expand description

A masked array that pairs data with a boolean mask.

Each element position has a corresponding mask bit:

  • true means the element is masked (invalid / missing)
  • false means the element is valid

All operations (arithmetic, reductions, ufuncs) respect the mask by skipping masked elements.

The fill_value field is the replacement value for masked positions when the masked array participates in operations or when MaskedArray::filled is called without an explicit override. It defaults to T::zero().

§Nomask sentinel (#506)

When a MaskedArray is constructed via MaskedArray::from_data the mask is logically “all-false” but is NOT allocated as a full Array<bool, D> up front — the lazy OnceLock inside stores nothing until the first call to MaskedArray::mask. For arrays that never touch their mask (e.g. masked ops that short-circuit via MaskedArray::has_real_mask), this saves a full bool-sized allocation proportional to the data size.

The .mask() accessor still returns &Array<bool, D> so all existing code continues to work unchanged; the cost is one lazy allocation on first access. Hot-path code that wants to avoid the materialization should check has_real_mask() first and skip any mask work when it returns false.

Implementations§

Source§

impl<T, D> MaskedArray<T, D>
where T: Element + Copy + Mul<Output = T> + One, D: Dimension,

Source

pub fn prod(&self) -> FerrayResult<T>

Product of unmasked elements. Returns T::one() for the all-masked case.

§Errors

Returns an error only for internal failures.

Source§

impl<T, D> MaskedArray<T, D>
where T: Element + Copy + Add<Output = T> + Zero, D: Dimension,

Source

pub fn cumsum_flat(&self) -> FerrayResult<MaskedArray<T, Ix1>>

Cumulative sum over unmasked elements (mask propagates: each output position carries the same mask as the input). Masked positions contribute zero to the running total.

§Errors

Returns an error if internal array construction fails.

Source§

impl<T, D> MaskedArray<T, D>
where T: Element + Copy + Mul<Output = T> + One, D: Dimension,

Source

pub fn cumprod_flat(&self) -> FerrayResult<MaskedArray<T, Ix1>>

Cumulative product over unmasked elements (mask propagates). Masked positions contribute one to the running product.

§Errors

Returns an error if internal array construction fails.

Source§

impl<T, D> MaskedArray<T, D>
where T: Element + Copy + PartialOrd, D: Dimension,

Source

pub fn argmin(&self) -> FerrayResult<usize>

Flat index of the minimum unmasked element.

§Errors

Returns FerrayError::InvalidValue if every element is masked.

Source

pub fn argmax(&self) -> FerrayResult<usize>

Flat index of the maximum unmasked element.

§Errors

Returns FerrayError::InvalidValue if every element is masked.

Source

pub fn ptp(&self) -> FerrayResult<T>
where T: Sub<Output = T>,

Peak-to-peak range over unmasked elements (max - min).

§Errors

Returns FerrayError::InvalidValue if every element is masked.

Source§

impl<T, D> MaskedArray<T, D>
where T: Element + Copy + PartialOrd + FromPrimitive + Add<Output = T> + Div<Output = T>, D: Dimension,

Source

pub fn median(&self) -> FerrayResult<T>

Median of unmasked elements (interpolated between the two middle values for an even count).

§Errors

Returns FerrayError::InvalidValue if every element is masked.

Source§

impl<T, D> MaskedArray<T, D>
where T: Element + Copy + Float, D: Dimension,

Source

pub fn average(&self, weights: Option<&Array<T, D>>) -> FerrayResult<T>

Weighted average of unmasked elements.

weights must be Some(Array<T, D>) of the same shape as self, or None (delegates to MaskedArray::mean).

§Errors

Returns FerrayError::ShapeMismatch if weights shape differs, or FerrayError::InvalidValue if the weight sum over unmasked elements is zero (or every element is masked).

Source

pub fn anom(&self) -> FerrayResult<MaskedArray<T, D>>

Anomaly array: self - mean(self). Returns a masked array of the same shape with the same mask.

Equivalent to numpy.ma.anom.

§Errors

Returns FerrayError::InvalidValue if every element is masked.

Source§

impl<T, D> MaskedArray<T, D>
where T: Element + Copy + PartialOrd, D: Dimension,

Source

pub fn clip(&self, a_min: T, a_max: T) -> FerrayResult<MaskedArray<T, D>>

Clip each unmasked element to [a_min, a_max]. Masked elements pass through unchanged. Equivalent to numpy.ma.clip.

§Errors

Returns an error if internal array construction fails.

Source§

impl<T, D> MaskedArray<T, D>
where T: Element + Copy, D: Dimension,

Source

pub fn repeat(&self, repeats: usize) -> FerrayResult<MaskedArray<T, Ix1>>

Repeat each unmasked element repeats times along the flat axis. Always returns a 1-D masked array.

Equivalent to numpy.ma.repeat(arr, repeats) with default flat axis.

§Errors

Returns an error if internal array construction fails.

Source

pub fn atleast_1d(&self) -> FerrayResult<MaskedArray<T, IxDyn>>

Promote to at least 1-D. Scalar (0-D) becomes shape (1,).

§Errors

Returns an error if internal array construction fails.

Source

pub fn atleast_2d(&self) -> FerrayResult<MaskedArray<T, IxDyn>>

Promote to at least 2-D. 0-D → (1,1); 1-D (N,) → (1, N).

§Errors

Returns an error if internal array construction fails.

Source

pub fn atleast_3d(&self) -> FerrayResult<MaskedArray<T, IxDyn>>

Promote to at least 3-D. See atleast_3d for the rank ladder.

§Errors

Returns an error if internal array construction fails.

Source

pub fn expand_dims(&self, axis: usize) -> FerrayResult<MaskedArray<T, IxDyn>>

Insert an axis of length 1 at the given position.

§Errors

Returns FerrayError::AxisOutOfBounds if axis > ndim.

Source§

impl<T> MaskedArray<T, Ix2>
where T: Element + Copy + Zero,

Source

pub fn diagonal(&self, k: isize) -> FerrayResult<MaskedArray<T, Ix1>>

Extract the k-th diagonal of a 2-D masked array as a 1-D masked array.

Equivalent to numpy.ma.diagonal for the 2-D case.

§Errors

Returns an error if internal array construction fails.

Source§

impl<T, D> MaskedArray<T, D>
where T: Element + Copy + Add<Output = T> + Mul<Output = T> + Zero, D: Dimension,

Source

pub fn ma_dot_flat(&self, other: &MaskedArray<T, D>) -> FerrayResult<T>

Inner product of two masked arrays as flat 1-D vectors. Masked positions on either side contribute zero.

§Errors

Returns FerrayError::ShapeMismatch if total element counts differ.

Source§

impl<T> MaskedArray<T, Ix2>
where T: Element + Copy + Add<Output = T> + Mul<Output = T> + Zero,

Source

pub fn trace(&self, k: isize) -> FerrayResult<T>

Trace (sum of diagonal) of a 2-D masked array. Masked diagonal elements contribute zero.

Source§

impl<T, D> MaskedArray<T, D>
where T: Element + Copy, D: Dimension,

Source

pub fn filled(&self, fill_value: T) -> FerrayResult<Array<T, D>>

Return a regular array with masked positions replaced by fill_value.

Unmasked positions retain their original data values.

§Errors

Returns an error only for internal failures.

Source

pub fn filled_default(&self) -> FerrayResult<Array<T, D>>

Return a regular array with masked positions replaced by the array’s stored MaskedArray::fill_value.

Equivalent to NumPy’s arr.filled() with no argument. Use MaskedArray::filled to override the fill value for a single call.

§Errors

Returns an error only for internal failures.

Source

pub fn compressed(&self) -> FerrayResult<Array<T, Ix1>>

Return a 1-D array containing only the unmasked elements.

The order is the logical (row-major) iteration order of the original array, with masked elements removed.

§Errors

Returns an error only for internal failures.

Source§

impl<T, D> MaskedArray<T, D>
where T: Element + Copy, D: Dimension,

Source

pub fn into_data(self) -> Array<T, D>

Consume the masked array and return its underlying data array, dropping the mask.

Use MaskedArray::filled_default (or MaskedArray::filled) if you want masked positions replaced by a sentinel value before dropping the mask.

Source

pub fn apply_unary<F>(&self, f: F) -> FerrayResult<Self>
where F: FnOnce(&Array<T, D>) -> FerrayResult<Array<T, D>>,

Apply a unary function to the underlying data and re-attach the mask, propagating it to the result.

The function f is called on the entire data array — masked positions are processed alongside unmasked ones, but their values in the result are immediately overwritten with the masked array’s fill_value. This matches NumPy’s __array_ufunc__ semantics where ufuncs run over the raw data and the mask is propagated separately.

§Example
// Apply ferray-ufunc::sin to a masked f64 array:
let result = ma.apply_unary(|arr| ferray_ufunc::sin(arr))?;
§Errors

Forwards any error from f.

Source

pub fn apply_unary_to<U, F>( &self, f: F, default_for_masked: U, ) -> FerrayResult<MaskedArray<U, D>>
where U: Element + Copy, F: FnOnce(&Array<T, D>) -> FerrayResult<Array<U, D>>,

Apply a unary function that maps T -> U, propagating the mask.

This is the type-changing variant of MaskedArray::apply_unary, useful for predicates like isnan that return Array<bool, D> from Array<T, D>. Masked positions in the result hold the explicitly supplied default_for_masked value.

§Errors

Forwards any error from f. Returns FerrayError::ShapeMismatch if f produces an array with a different shape.

Source

pub fn apply_binary<F>(&self, other: &Self, f: F) -> FerrayResult<Self>
where F: FnOnce(&Array<T, D>, &Array<T, D>) -> FerrayResult<Array<T, D>>,

Apply a binary function to two masked arrays, propagating the mask union. Both inputs must have the same shape.

The function f is called on the underlying data of both inputs (no broadcasting — use crate::masked_add-style functions for that). The result mask is the OR of the two input masks; masked positions in the data are overwritten with the receiver’s fill_value.

§Example
let result = a.apply_binary(&b, |x, y| ferray_ufunc::power(x, y))?;
§Errors

Returns FerrayError::ShapeMismatch if shapes differ. Forwards any error from f.

Source§

impl<T: Element + Copy, D: Dimension> MaskedArray<T, D>

Source

pub fn reshape( &self, new_shape: &[usize], ) -> FerrayResult<MaskedArray<T, IxDyn>>

Return a new MaskedArray with the given shape.

Equivalent to numpy.ma.reshape(a, new_shape). The result is a dynamic-rank MaskedArray<T, IxDyn>. The total element count must match; mask and data are reshaped in lockstep so their logical positions remain aligned. The fill_value and hard_mask flag are preserved.

§Errors
  • FerrayError::ShapeMismatch if new_shape’s product does not equal self.size().
Source

pub fn ravel(&self) -> FerrayResult<MaskedArray<T, Ix1>>

Return a 1-D MaskedArray with the same total element count.

Equivalent to numpy.ma.ravel(a). Preserves fill_value and hard_mask.

Source

pub fn flatten(&self) -> FerrayResult<MaskedArray<T, Ix1>>

Alias for MaskedArray::ravel.

Equivalent to numpy.ma.flatten(a).

Source

pub fn transpose( &self, axes: Option<&[usize]>, ) -> FerrayResult<MaskedArray<T, IxDyn>>

Return a transposed MaskedArray by permuting axes.

When axes is None, reverses the axis order (equivalent to numpy.ma.transpose(a) or a.T). When Some(ax), uses the supplied permutation. Both data and mask are permuted together so their logical positions remain aligned.

Returns a dynamic-rank result because the permutation is chosen at runtime.

§Errors
  • FerrayError::InvalidValue if axes is the wrong length or not a valid permutation.
Source

pub fn t(&self) -> FerrayResult<MaskedArray<T, IxDyn>>

Return a transposed MaskedArray with reversed axis order.

Shorthand for self.transpose(None), equivalent to NumPy’s .T property.

Source

pub fn squeeze( &self, axis: Option<usize>, ) -> FerrayResult<MaskedArray<T, IxDyn>>

Remove size-1 axes from the masked array.

Equivalent to numpy.ma.squeeze(a). When axis is None, removes every axis whose length is 1. When Some(ax), only the specified axis (which must have length 1) is removed.

The single-axis restriction mirrors ferray_core::manipulation::squeeze — chain multiple calls if you need to drop several axes.

Source§

impl<T: Element + Copy, D: Dimension> MaskedArray<T, D>

Source

pub fn get_flat(&self, flat_idx: usize) -> FerrayResult<(T, bool)>

Get a single element by flat (row-major) index.

Returns Ok((value, is_masked)) where is_masked is true when the mask bit at that position is set. Returns an error if the index is out of bounds.

Returning the raw (T, bool) pair lets callers decide what to do with masked values instead of forcing a fill-value substitution — if you want the NumPy-style masked scalar behavior, check is_masked and fall back to self.fill_value().

§Errors
  • FerrayError::IndexOutOfBounds if flat_idx >= self.size().
Source

pub fn boolean_index( &self, bool_mask: &Array<bool, D>, ) -> FerrayResult<MaskedArray<T, Ix1>>

Select elements where bool_mask is true.

Equivalent to a[bool_mask] in NumPy boolean indexing. Returns a 1-D MaskedArray containing only positions where the supplied bool_mask is true; each selected position carries through both its value and its original mask bit. The bool_mask must have exactly the same shape as self.

§Errors
  • FerrayError::ShapeMismatch if bool_mask.shape() != self.shape().
Source

pub fn take(&self, indices: &[usize]) -> FerrayResult<MaskedArray<T, Ix1>>
where D: Dimension,

Fancy index selection from a 1-D MaskedArray.

Equivalent to a[indices] in NumPy fancy indexing (restricted to 1-D because higher-rank fancy indexing has NumPy-specific broadcasting semantics that would be easy to get subtly wrong). Returns a new 1-D MaskedArray whose elements are picked from self at the supplied flat positions.

Each result position carries through both the selected value and its original mask bit.

§Errors
  • FerrayError::IndexOutOfBounds if any index is out of range.
Source§

impl<T: Element, D: Dimension> MaskedArray<T, D>

Source

pub const fn harden_mask(&mut self) -> FerrayResult<()>

Harden the mask: prevent subsequent assignments from clearing mask bits.

After this call, any attempt to set a mask bit to false via set_mask_flat or set_mask will be silently ignored.

§Errors

This function does not currently error but returns Result for API consistency.

Source

pub const fn soften_mask(&mut self) -> FerrayResult<()>

Soften the mask: allow subsequent assignments to clear mask bits.

§Errors

This function does not currently error but returns Result for API consistency.

Source§

impl<T: Element, D: Dimension> MaskedArray<T, D>

Source

pub fn new(data: Array<T, D>, mask: Array<bool, D>) -> FerrayResult<Self>

Create a new masked array from data and mask arrays.

The fill_value defaults to T::zero(). Use MaskedArray::with_fill_value to set a custom replacement value.

§Errors

Returns FerrayError::ShapeMismatch if data and mask shapes differ.

Source

pub fn from_data(data: Array<T, D>) -> FerrayResult<Self>

Create a masked array with no masked elements (all-false mask).

Does NOT allocate the mask up front — the array is in the nomask-sentinel state (#506) until MaskedArray::mask is explicitly called. For code that only uses data() or short-circuits via MaskedArray::has_real_mask, this saves a full-sized bool allocation.

§Errors

Always returns Ok — the FerrayResult is preserved for API parity with the previous eager implementation.

Source

pub const fn has_real_mask(&self) -> bool

Return true if this masked array holds a real (explicitly provided or materialized) mask. Returns false when the array is in the nomask-sentinel state and the mask is logically all-false.

Hot-path iteration code should branch on this flag to skip mask scanning entirely when it returns false (#506).

Source

pub const fn fill_value(&self) -> T
where T: Copy,

Return the fill value used to replace masked positions.

See MaskedArray::with_fill_value for setting it.

Source

pub fn with_fill_value(self, fill_value: T) -> Self

Set the fill value, returning the modified array.

The fill value is used by MaskedArray::filled (when called without an explicit override) and by arithmetic operations as the replacement for masked positions in the result data.

Source

pub fn set_fill_value(&mut self, fill_value: T)

Replace the fill value in place.

Source

pub const fn data(&self) -> &Array<T, D>

Return a reference to the underlying data array.

Source

pub fn mask(&self) -> &Array<bool, D>

Return a reference to the mask array.

If the array is in the nomask-sentinel state (constructed via MaskedArray::from_data or otherwise) this lazily allocates a full all-false Array<bool, D> and caches it for subsequent calls. Use MaskedArray::has_real_mask to check whether the mask is known to be trivial first, and skip calling .mask() entirely on the hot path when you can.

Source

pub fn mask_opt(&self) -> Option<&Array<bool, D>>

Return a reference to the mask array if one has been materialized, or None when the array is still in the nomask-sentinel state.

Unlike MaskedArray::mask, this does NOT trigger lazy allocation — it’s the fast-path query for hot code that wants to branch on whether any mask bits are set (#506).

Source

pub const fn data_mut(&mut self) -> &mut Array<T, D>

Return a mutable reference to the underlying data array.

Source

pub fn shape(&self) -> &[usize]

Return the shape of the masked array.

Source

pub fn ndim(&self) -> usize

Return the number of dimensions.

Source

pub fn size(&self) -> usize

Return the total number of elements (including masked).

Source

pub const fn dim(&self) -> &D

Return the dimension descriptor.

Source

pub const fn is_hard_mask(&self) -> bool

Return whether the mask is hardened.

Source

pub fn set_mask_flat( &mut self, flat_idx: usize, value: bool, ) -> FerrayResult<()>

Set a mask value at a flat index.

If the mask is hardened, only true (masking) is allowed; attempts to clear a mask bit are silently ignored.

Setting a mask bit materializes the lazy nomask sentinel into a real mask array (#506) — if you set even one bit, the full Array<bool, D> is allocated.

§Errors

Returns FerrayError::IndexOutOfBounds if flat_idx >= size.

Source

pub fn set_mask(&mut self, new_mask: Array<bool, D>) -> FerrayResult<()>

Replace the mask with a new one.

If the mask is hardened, only bits that are true in both the old and new masks (or newly set to true) are allowed; cleared bits are ignored.

Passing a new mask always materializes the array out of the nomask-sentinel state — the stored mask becomes the provided one (possibly unioned with the existing mask if hardened).

§Errors

Returns FerrayError::ShapeMismatch if shapes differ.

Source

pub fn shares_mask(&self) -> bool

Return true when this masked array’s underlying mask is structurally shared with at least one other MaskedArray.

After a clone() the original and the clone share the same mask via Arc until one of them mutates it (copy-on-write, #512). Hot-path code can use this to reason about memory sharing — shares_mask() == false means the mask is uniquely owned and can be mutated without affecting any other MaskedArray.

Source§

impl<T, D> MaskedArray<T, D>
where T: Element + Copy, D: Dimension,

Source

pub fn count(&self) -> FerrayResult<usize>

Count the number of unmasked (valid) elements.

§Errors

This function does not currently error but returns Result for API consistency.

Source

pub fn count_axis(&self, axis: usize) -> FerrayResult<Array<u64, IxDyn>>

Count the number of unmasked elements per lane along axis.

Returns a plain Array<u64, IxDyn> (not masked, since count is always defined) with the reduced axis removed.

§Errors

Returns FerrayError::AxisOutOfBounds if axis >= ndim.

Source§

impl<T, D> MaskedArray<T, D>
where T: Element + Float, D: Dimension,

Source

pub fn sum(&self) -> FerrayResult<T>

Compute the sum of unmasked elements.

Returns zero if all elements are masked.

§Errors

Returns an error only for internal failures.

Source

pub fn mean(&self) -> FerrayResult<T>

Compute the mean of unmasked elements.

Returns NaN if no elements are unmasked.

§Errors

Returns an error only for internal failures.

Source

pub fn min(&self) -> FerrayResult<T>

Compute the minimum of unmasked elements.

NaN values in unmasked elements are propagated (returns NaN), matching NumPy.

§Errors

Returns FerrayError::InvalidValue if no elements are unmasked.

Source

pub fn max(&self) -> FerrayResult<T>

Compute the maximum of unmasked elements.

NaN values in unmasked elements are propagated (returns NaN), matching NumPy.

§Errors

Returns FerrayError::InvalidValue if no elements are unmasked.

Source

pub fn var(&self) -> FerrayResult<T>

Compute the variance of unmasked elements (population variance, ddof=0).

Returns NaN if no elements are unmasked.

§Errors

Returns an error only for internal failures.

Source

pub fn std(&self) -> FerrayResult<T>

Compute the standard deviation of unmasked elements (population, ddof=0).

Returns NaN if no elements are unmasked.

§Errors

Returns an error only for internal failures.

Source

pub fn sum_axis(&self, axis: usize) -> FerrayResult<MaskedArray<T, IxDyn>>

Sum unmasked elements along axis. Returns a masked array with the reduced axis removed; lanes that are entirely masked produce a masked output position holding fill_value.

Source

pub fn mean_axis(&self, axis: usize) -> FerrayResult<MaskedArray<T, IxDyn>>

Mean of unmasked elements along axis. All-masked lanes are masked in the output.

Source

pub fn min_axis(&self, axis: usize) -> FerrayResult<MaskedArray<T, IxDyn>>

Min of unmasked elements along axis. NaN-propagating per NumPy.

Source

pub fn max_axis(&self, axis: usize) -> FerrayResult<MaskedArray<T, IxDyn>>

Max of unmasked elements along axis. NaN-propagating per NumPy.

Source

pub fn var_axis(&self, axis: usize) -> FerrayResult<MaskedArray<T, IxDyn>>

Population variance (ddof=0) of unmasked elements along axis.

Source

pub fn std_axis(&self, axis: usize) -> FerrayResult<MaskedArray<T, IxDyn>>

Population standard deviation (ddof=0) of unmasked elements along axis.

Source§

impl<T, D> MaskedArray<T, D>
where T: Element + PartialOrd + Copy, D: Dimension,

Source

pub fn sort(&self) -> FerrayResult<MaskedArray<T, Ix1>>

Sort the masked array (flattened), placing masked elements at the end.

Returns a new 1-D MaskedArray where:

  • Unmasked elements are sorted in ascending order
  • Masked elements come after all unmasked elements
§Errors

Returns an error only for internal failures.

Source

pub fn argsort(&self) -> FerrayResult<Vec<usize>>

Return the indices that would sort the masked array, with masked elements placed at the end.

Returns a Vec<usize> of indices.

§Errors

Returns an error only for internal failures.

Trait Implementations§

Source§

impl<T, D> Add<&MaskedArray<T, D>> for &MaskedArray<T, D>
where T: Element + Add<Output = T> + Copy, D: Dimension,

&MaskedArray + &MaskedArray — elementwise add with mask union.

Source§

type Output = Result<MaskedArray<T, D>, FerrayError>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &MaskedArray<T, D>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: Element, D: Dimension> AsRef<Array<T, D>> for MaskedArray<T, D>

Source§

fn as_ref(&self) -> &Array<T, D>

Borrow the underlying data array, dropping the mask.

This lets you pass a &MaskedArray<T, D> to any function that takes &Array<T, D>, but the mask is not consulted — masked positions will be processed like normal data. Use MaskedArray::apply_unary or MaskedArray::apply_binary when you want mask propagation.

§Example
let ma = MaskedArray::new(data, mask).unwrap();
// Pass through a function that operates on `&Array<T, D>`:
let arr_ref: &Array<f64, Ix1> = ma.as_ref();
assert_eq!(arr_ref.shape(), &[3]);
Source§

impl<T: Element + Clone, D: Dimension> Clone for MaskedArray<T, D>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Element, D: Dimension> Debug for MaskedArray<T, D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, D> Div<&MaskedArray<T, D>> for &MaskedArray<T, D>
where T: Element + Div<Output = T> + Copy, D: Dimension,

&MaskedArray / &MaskedArray — elementwise divide with mask union.

Source§

type Output = Result<MaskedArray<T, D>, FerrayError>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &MaskedArray<T, D>) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: Element + Copy, D: Dimension> From<MaskedArray<T, D>> for Array<T, D>

Source§

fn from(ma: MaskedArray<T, D>) -> Self

Consume a MaskedArray and return its underlying data array, discarding the mask. Equivalent to calling ma.into_data().

Requires T: Copy because the underlying data buffer is cloned; use MaskedArray::filled / MaskedArray::filled_default for a mask-aware materialization with custom fill semantics.

Source§

impl<T: Element, D: Dimension> MaskAware<T, D> for MaskedArray<T, D>

Source§

fn data(&self) -> &Array<T, D>

Return a reference to the underlying data array.
Source§

fn mask_opt(&self) -> Option<&Array<bool, D>>

Return the mask array if one is explicitly present, or None when the input carries no mask (treated as fully unmasked). Read more
Source§

fn fill_value(&self) -> T
where T: Copy,

Return the fill value to use for masked positions in derived results.
Source§

fn shape(&self) -> &[usize]

Return the shape of the underlying data.
Source§

impl<T, D> Mul<&MaskedArray<T, D>> for &MaskedArray<T, D>
where T: Element + Mul<Output = T> + Copy, D: Dimension,

&MaskedArray * &MaskedArray — elementwise multiply with mask union.

Source§

type Output = Result<MaskedArray<T, D>, FerrayError>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &MaskedArray<T, D>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T, D> Sub<&MaskedArray<T, D>> for &MaskedArray<T, D>
where T: Element + Sub<Output = T> + Copy, D: Dimension,

&MaskedArray - &MaskedArray — elementwise subtract with mask union.

Source§

type Output = Result<MaskedArray<T, D>, FerrayError>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &MaskedArray<T, D>) -> Self::Output

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<T, D> Freeze for MaskedArray<T, D>
where T: Freeze, D: Freeze, <D as Dimension>::NdarrayDim: Freeze,

§

impl<T, D> RefUnwindSafe for MaskedArray<T, D>

§

impl<T, D> Send for MaskedArray<T, D>

§

impl<T, D> Sync for MaskedArray<T, D>

§

impl<T, D> Unpin for MaskedArray<T, D>
where T: Unpin, D: Unpin, <D as Dimension>::NdarrayDim: Unpin,

§

impl<T, D> UnsafeUnpin for MaskedArray<T, D>

§

impl<T, D> UnwindSafe for MaskedArray<T, D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.