Table of Contents

Class NDMaskedConstant

Namespace
NumSharp
Assembly
NumSharp.dll

NumPy's numpy.ma.masked singleton: the scalar constant that represents "a single masked value". A masked ufunc that reduces to one fully-masked 0-D element returns this instance, matching NumPy where np.ma.add(masked, x) and a masked 0-D result are masked.

public sealed class NDMaskedConstant : NDMaskedArray
Inheritance
NDMaskedConstant
Inherited Members

Remarks

The library builds ONE instance, reachable under four names that are all the same object: NDMasked / NDMaskedSingleton (NumSharp's ND* spelling) and masked / masked_singleton (NumPy's names), and every masked function returns that one, so reference identity (ReferenceEquals(r, np.ma.masked)) is the C# counterpart of NumPy's r is np.ma.masked. The constructor is public, so code can build further instances; see its footgun.

Constructors

NDMaskedConstant()

Builds the constant as a 0-D 0.0 datum under a 0-D True mask, i.e. one masked scalar — the same internal shape NumPy's masked_singleton carries.

public NDMaskedConstant()

Remarks

Both scalars are detached from every scope (Own(NDArray)): the single instance is built during np's static initialization, which may run inside a caller's open NDScope; left tracked, that scope would dispose the singleton's buffers on close.

Footgun: NumPy's MaskedConstant() returns the existing singleton, but a C# constructor always builds a NEW object. Library code recognises the masked scalar both ways - five type tests (is NDMaskedConstant) accept another instance, while nine identity tests (ReferenceEquals(x, np.ma.masked): the var / std / average and set-operation paths) treat it as an ordinary fully masked scalar. Use masked rather than building one.

Methods

ToString()

Renders as the bare token masked, as NumPy prints its singleton.

public override string ToString()

Returns

string

The string "masked".