Struct MaskedArrayModule.AverageResult
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
The result of average(object, int?, object, bool, bool) - NumPy's bare-masked-average-OR-tuple
return as one type: the masked average (values, typed NDMaskedArray), plus
sum_of_weights when returned was set (null otherwise). It converts implicitly to
NDMaskedArray and deconstructs: var (avg, sum_of_weights) = np.ma.average(a, returned:
true);.
public readonly struct MaskedArrayModule.AverageResult : INDArrayCarrier
- Implements
- Inherited Members
Remarks
API-parity batch 11 (the owner's decision 3): it replaces np.ma.average's NDMaskedArray return and the
NumSharp-only np.ma.average_returned. Its constructor is internal: only np.ma.average builds it, so
values is always the masked average. The masked array's members callers read on an average
(data, mask, shape, dtype, size, filled) forward to values.
Footgun: an extension method of NDMaskedArray does not see through the implicit conversion - call it on values.
Properties
Length
Number of present outputs: 1, or 2 with returned.
public int Length { get; }
Property Value
data
The average's data (data).
public NDArray data { get; }
Property Value
dtype
The average's dtype.
public DType dtype { get; }
Property Value
mask
The average's mask (mask).
public NDArray mask { get; }
Property Value
shape
The average's shape.
public long[] shape { get; }
Property Value
- long[]
size
The average's element count.
public long size { get; }
Property Value
sum_of_weights
The sum of weights in the average's shape (the unmasked count without weights), or null
when returned was false. NumPy's is a MaskedArray or an ndarray depending on the case; here it is
whichever the computation produced, typed NDArray.
public NDArray sum_of_weights { get; }
Property Value
values
The masked average (0-d over every axis; a full reduction of a fully masked operand is masked). Always present.
public NDMaskedArray values { get; }
Property Value
Methods
Deconstruct(out NDMaskedArray, out NDArray)
Deconstructs a returned=True result: var (avg, sum_of_weights) = ....
public void Deconstruct(out NDMaskedArray values, out NDArray sum_of_weights)
Parameters
valuesNDMaskedArrayThe masked average.
sum_of_weightsNDArrayThe sum of weights.
Exceptions
- InvalidOperationException
The result holds the average alone: Python's
not enough values to unpack (expected 2, got 1).
filled(object)
The average with its masked slots replaced (filled(object)).
public NDArray filled(object fill_value = null)
Parameters
fill_valueobjectThe value for the masked slots, or null for the average's fill value.
Returns
- NDArray
A plain array.
Operators
implicit operator NDMaskedArray(AverageResult)
The masked average: NumPy's first tuple element, and the whole result without returned.
public static implicit operator NDMaskedArray(MaskedArrayModule.AverageResult result)
Parameters
resultMaskedArrayModule.AverageResultThe result.