Documentation
¶
Overview ¶
Package ma provides numpy.ma-style masked arrays over numgo.Array (numpy/ma/core.py semantics, narrowed to this batch — see docs/design.md §2).
A Masked pairs a data array with a parallel mask: true marks an element as invalid. The mask is always materialized (a []bool whose length equals the data's Size) and is indexed in C order of the data's LOGICAL shape, so it stays aligned no matter what view the underlying data is.
Semantics for this batch:
- Constructors copy their inputs; operations are pure (new Masked). There are no zero-copy views: shape ops rebuild the mask for the new shape.
- Element-wise ops OR the operand masks. Div additionally masks positions where the divisor is zero (numpy ma domain behavior: warnings become mask bits, the IEEE value stays in the data).
- Reductions ignore masked elements. A slice with no unmasked elements yields a NaN value that is itself masked (numpy returns a masked element after RuntimeWarning).
- ArgMax/ArgMin skip masked entries and return -1 for an all-masked channel (numpy returns a masked index).
- Any/All consider unmasked values only; a Go bool cannot express numpy's masked answer, so all-masked input gives Any=false, All=true (vacuous).
- FilledDefault fills with numpy's default fill table for float/complex: 1e20 (complex real part 1e20), matching np.ma.default_fill_value.
- SetUnmasked writes the value and clears the mask bit; under a hard mask a masked position silently refuses the write (numpy behavior).
Index ¶
- type Masked
- func Concatenate[T numgo.Number](axis int, as ...*Masked[T]) *Masked[T]
- func FromData[T numgo.Number](data *numgo.Array[T], mask []bool) *Masked[T]
- func MaskedAll[T numgo.Number](shape ...int) *Masked[T]
- func MaskedEqual[T numgo.Number](a *numgo.Array[T], v T) *Masked[T]
- func MaskedFull[T numgo.Number](v T, shape ...int) *Masked[T]
- func MaskedGreater[T numgo.Number](a *numgo.Array[T], v T) *Masked[T]
- func MaskedGreaterEqual[T numgo.Number](a *numgo.Array[T], v T) *Masked[T]
- func MaskedInside[T numgo.Number](a *numgo.Array[T], v1, v2 T) *Masked[T]
- func MaskedInvalid[T numgo.Number](a *numgo.Array[T]) *Masked[T]
- func MaskedLess[T numgo.Number](a *numgo.Array[T], v T) *Masked[T]
- func MaskedLessEqual[T numgo.Number](a *numgo.Array[T], v T) *Masked[T]
- func MaskedNotEqual[T numgo.Number](a *numgo.Array[T], v T) *Masked[T]
- func MaskedOnes[T numgo.Number](shape ...int) *Masked[T]
- func MaskedOutside[T numgo.Number](a *numgo.Array[T], v1, v2 T) *Masked[T]
- func MaskedWhere[T numgo.Number](cond []bool, a *numgo.Array[T]) *Masked[T]
- func MaskedZeros[T numgo.Number](shape ...int) *Masked[T]
- func New[T numgo.Number](a *numgo.Array[T]) *Masked[T]
- func Reshape[T numgo.Number](m *Masked[T], shape ...int) *Masked[T]
- func Squeeze[T numgo.Number](m *Masked[T], axes ...int) *Masked[T]
- func Stack[T numgo.Number](axis int, as ...*Masked[T]) *Masked[T]
- func Transpose[T numgo.Number](m *Masked[T], axes ...int) *Masked[T]
- func (m *Masked[T]) Abs() *Masked[T]
- func (m *Masked[T]) Add(b *Masked[T]) *Masked[T]
- func (m *Masked[T]) AddValue(v T) *Masked[T]
- func (m *Masked[T]) All() bool
- func (m *Masked[T]) Any() bool
- func (m *Masked[T]) ArgMax(axis int) []int
- func (m *Masked[T]) ArgMin(axis int) []int
- func (m *Masked[T]) Ceil() *Masked[T]
- func (m *Masked[T]) Compressed() *numgo.Array[T]
- func (m *Masked[T]) Copy() *Masked[T]
- func (m *Masked[T]) Cos() *Masked[T]
- func (m *Masked[T]) CountUnmasked() int
- func (m *Masked[T]) CumProd(axes ...int) *Masked[T]
- func (m *Masked[T]) CumSum(axes ...int) *Masked[T]
- func (m *Masked[T]) Data() *numgo.Array[T]
- func (m *Masked[T]) Div(b *Masked[T]) *Masked[T]
- func (m *Masked[T]) DivValue(v T) *Masked[T]
- func (m *Masked[T]) Exp() *Masked[T]
- func (m *Masked[T]) Filled(fill T) *numgo.Array[T]
- func (m *Masked[T]) FilledDefault() *numgo.Array[T]
- func (m *Masked[T]) Floor() *Masked[T]
- func (m *Masked[T]) HardMask() *Masked[T]
- func (m *Masked[T]) Log() *Masked[T]
- func (m *Masked[T]) Log1p() *Masked[T]
- func (m *Masked[T]) Log2() *Masked[T]
- func (m *Masked[T]) Log10() *Masked[T]
- func (m *Masked[T]) Mask() []bool
- func (m *Masked[T]) Max(axes ...int) *Masked[T]
- func (m *Masked[T]) MaxKeepdims(axes ...int) *Masked[T]
- func (m *Masked[T]) Mean(axes ...int) *Masked[T]
- func (m *Masked[T]) MeanKeepdims(axes ...int) *Masked[T]
- func (m *Masked[T]) Min(axes ...int) *Masked[T]
- func (m *Masked[T]) MinKeepdims(axes ...int) *Masked[T]
- func (m *Masked[T]) Mul(b *Masked[T]) *Masked[T]
- func (m *Masked[T]) MulValue(v T) *Masked[T]
- func (m *Masked[T]) Ndim() int
- func (m *Masked[T]) Neg() *Masked[T]
- func (m *Masked[T]) Pow(b *Masked[T]) *Masked[T]
- func (m *Masked[T]) Round() *Masked[T]
- func (m *Masked[T]) SetUnmasked(coords []int, v T) *Masked[T]
- func (m *Masked[T]) Shape() []int
- func (m *Masked[T]) Sin() *Masked[T]
- func (m *Masked[T]) Size() int
- func (m *Masked[T]) SoftMask() *Masked[T]
- func (m *Masked[T]) Sqrt() *Masked[T]
- func (m *Masked[T]) Std(axes ...int) *Masked[T]
- func (m *Masked[T]) StdDDof(ddof int, axes ...int) *Masked[T]
- func (m *Masked[T]) Sub(b *Masked[T]) *Masked[T]
- func (m *Masked[T]) SubValue(v T) *Masked[T]
- func (m *Masked[T]) Sum(axes ...int) *Masked[T]
- func (m *Masked[T]) SumKeepdims(axes ...int) *Masked[T]
- func (m *Masked[T]) Tan() *Masked[T]
- func (m *Masked[T]) Var(axes ...int) *Masked[T]
- func (m *Masked[T]) VarDDof(ddof int, axes ...int) *Masked[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Masked ¶
Masked is a data array plus an element mask. mask[i] true means element i (C order of the logical shape) is invalid. The zero value is unusable; use the constructors.
func Concatenate ¶
Pure: Concatenate joins masked arrays along axis (negative allowed); masks merge by concatenation.
func FromData ¶
Pure: FromData builds a Masked from data and a mask, copying both. The mask length must equal data's Size.
func MaskedAll ¶
Pure: MaskedAll returns a Masked array with every element masked. The data carries zeros (numpy leaves whatever Empty produced; masked anyway).
func MaskedEqual ¶
Pure: MaskedEqual masks elements equal to v.
func MaskedFull ¶
Pure: MaskedFull returns a Masked array filled with v (nomask).
func MaskedGreater ¶
Pure: MaskedGreater masks elements strictly greater than v.
func MaskedGreaterEqual ¶
Pure: MaskedGreaterEqual masks elements greater than or equal to v.
func MaskedInside ¶
Pure: MaskedInside masks v1 <= x <= v2 (both inclusive).
func MaskedInvalid ¶
Pure: MaskedInvalid masks NaN and ±Inf elements (real and complex parts).
func MaskedLess ¶
Pure: MaskedLess masks elements strictly less than v.
func MaskedLessEqual ¶
Pure: MaskedLessEqual masks elements less than or equal to v.
func MaskedNotEqual ¶
Pure: MaskedNotEqual masks elements not equal to v.
func MaskedOnes ¶
Pure: MaskedOnes returns a Masked ones array (nomask).
func MaskedOutside ¶
Pure: MaskedOutside masks x < v1 or x > v2.
func MaskedWhere ¶
Pure: MaskedWhere masks cond true positions of a (flat C order).
func MaskedZeros ¶
Pure: MaskedZeros returns a Masked zeros array (nomask).
func Reshape ¶
Pure: Reshape re-shapes (at most one -1 dimension); the mask re-indexes in C order of the new shape. Masks are materialized in C order of the logical shape, so for contiguous data the mask carries over verbatim.
func Squeeze ¶
Pure: Squeeze drops size-1 dimensions (all when no axes given); the mask re-indexes in C order.
func Stack ¶
Pure: Stack joins same-shaped masked arrays along a new axis (negative allowed, ndim+1 positions valid).
func Transpose ¶
Pure: Transpose permutes axes (no axes = reverse); the mask permutes with the data.
func (*Masked[T]) All ¶
Pure: All reports whether every UNMASKED element is nonzero; masked elements are skipped, so all-masked input is vacuously true.
func (*Masked[T]) Any ¶
Pure: Any reports whether any UNMASKED element is nonzero. All-masked input returns false (a bool cannot carry numpy's masked answer).
func (*Masked[T]) ArgMax ¶
Pure: ArgMax returns the coordinate of each unmasked maximum along axis (first occurrence wins ties); an all-masked channel gives -1 (numpy returns a masked index).
func (*Masked[T]) ArgMin ¶
Pure: ArgMin returns the coordinate of each unmasked minimum along axis (first occurrence wins ties); an all-masked channel gives -1.
func (*Masked[T]) Compressed ¶
Pure: Compressed returns the unmasked elements as a new 1-D array in C order (numpy compressed()); possibly empty.
func (*Masked[T]) CountUnmasked ¶
Pure: CountUnmasked returns the number of valid elements.
func (*Masked[T]) CumSum ¶
Pure: CumSum prefixes unmasked sums along axes (no axes = C-order prefix over the raveled array); masked positions carry the running value forward without contributing (numpy ma cumsum).
func (*Masked[T]) Div ¶
Pure: Div returns the element-wise quotient. Positions where the divisor is zero are additionally masked (numpy ma: divide-by-zero warning becomes a mask bit; the IEEE result stays in the data).
func (*Masked[T]) DivValue ¶
Pure: DivValue divides every element by the scalar v (zero v masks, like Div).
func (*Masked[T]) Filled ¶
Pure: Filled returns a copy of the data with every masked element replaced by fill.
func (*Masked[T]) FilledDefault ¶
Pure: FilledDefault fills masked elements with numpy's default fill value for the element type: 1e20 (real part 1e20 for complex), per np.ma.default_fill_value.
func (*Masked[T]) HardMask ¶
Chainable: HardMask enables the hard mask: SetUnmasked silently refuses writes to masked positions (numpy hard_mask).
func (*Masked[T]) Log ¶
Pure: Log returns the natural logarithm; real elements < 0 are masked (Log(0) stays -Inf and unmasked, matching numpy's divide warning domain).
func (*Masked[T]) MaxKeepdims ¶
Pure: MaxKeepdims folds max keeping reduced axes as size 1.
func (*Masked[T]) MeanKeepdims ¶
Pure: MeanKeepdims folds the mean keeping reduced axes as size 1.
func (*Masked[T]) MinKeepdims ¶
Pure: MinKeepdims folds min keeping reduced axes as size 1.
func (*Masked[T]) Round ¶
Pure: Round returns the element-wise round-half-to-even (mask propagates only).
func (*Masked[T]) SetUnmasked ¶
In-place: SetUnmasked writes v at coords and clears the mask bit there. A masked position under a hard mask silently refuses the write and is returned unchanged (numpy behavior). Invalid coords panic.
func (*Masked[T]) Sqrt ¶
Pure: Sqrt returns the element-wise square root; negative real elements are masked (complex input uses the principal branch, no domain).
func (*Masked[T]) StdDDof ¶
Pure: StdDDof computes the unmasked standard deviation with the given ddof.
func (*Masked[T]) SumKeepdims ¶
Pure: SumKeepdims folds the sum keeping reduced axes as size 1.