Table of Contents

Class DTypeRegistry

Namespace
NumSharp
Assembly
NumSharp.dll

The table of live DTypeMeta classes and their casting implementations — NumPy's _builtin_descrs / typenum_to_dtypemeta / _PyArray_MapPyTypeToDType rolled into one static registry. Lookups by NPTypeCode, C# scalar Type, NumPy type number and class name (aliases included); Register(DTypeMeta) admits a new class (a Stage C/D dtype, a user dtype) without touching the kernel switches — the class registers its code and its casts, and the promotion/casting engines pick it up.

public static class DTypeRegistry
Inheritance
DTypeRegistry
Inherited Members

Remarks

Static initialisation builds the 16 legacy classes (the 15 storage types plus the vestigial String), the two datetime classes, the three NEP 50 scalar classes, their singleton descriptors, and the casting implementations NumPy registers in PyArray_InitializeNumericCasts / PyArray_InitializeDatetimeCasts. It touches no np static state, so it cannot cycle with the np static constructor; the promotion TABLE (NumSharp.np._nptypemap_arr_arr) is consulted lazily at call time.

Properties

All

Every registered class (builtins, datetime pair, the abstract scalar classes, user classes).

public static IReadOnlyList<DTypeMeta> All { get; }

Property Value

IReadOnlyList<DTypeMeta>

Bool

public static LegacyBuiltinDTypeMeta Bool { get; }

Property Value

LegacyBuiltinDTypeMeta

Char

NumSharp-only: char (type number 257, the user-defined range; promotes as uint16).

public static LegacyBuiltinDTypeMeta Char { get; }

Property Value

LegacyBuiltinDTypeMeta

Complex128

public static LegacyBuiltinDTypeMeta Complex128 { get; }

Property Value

LegacyBuiltinDTypeMeta

DateTime64

np.dtypes.DateTime64DType.

public static DatetimeDTypeMeta DateTime64 { get; }

Property Value

DatetimeDTypeMeta

Decimal

NumSharp-only: decimal (type number 256, the user-defined range).

public static LegacyBuiltinDTypeMeta Decimal { get; }

Property Value

LegacyBuiltinDTypeMeta

Double

public static LegacyBuiltinDTypeMeta Double { get; }

Property Value

LegacyBuiltinDTypeMeta

Half

public static LegacyBuiltinDTypeMeta Half { get; }

Property Value

LegacyBuiltinDTypeMeta

Int16

public static LegacyBuiltinDTypeMeta Int16 { get; }

Property Value

LegacyBuiltinDTypeMeta

Int32

public static LegacyBuiltinDTypeMeta Int32 { get; }

Property Value

LegacyBuiltinDTypeMeta

Int64

public static LegacyBuiltinDTypeMeta Int64 { get; }

Property Value

LegacyBuiltinDTypeMeta

Int8

public static LegacyBuiltinDTypeMeta Int8 { get; }

Property Value

LegacyBuiltinDTypeMeta

PyComplex

NEP 50's _PyComplexDType — the class of a weak C# Complex literal.

public static PyScalarDTypeMeta PyComplex { get; }

Property Value

PyScalarDTypeMeta

PyFloat

NEP 50's _PyFloatDType — the class of a weak C# floating literal.

public static PyScalarDTypeMeta PyFloat { get; }

Property Value

PyScalarDTypeMeta

PyLong

NEP 50's _PyLongDType — the class of a weak C# integer literal.

public static PyScalarDTypeMeta PyLong { get; }

Property Value

PyScalarDTypeMeta

Single

public static LegacyBuiltinDTypeMeta Single { get; }

Property Value

LegacyBuiltinDTypeMeta

Str

The vestigial String class (NumPy's StrDType slot, type number 19): reachable only through the "string"/"String" aliases, no storage kernels.

public static LegacyBuiltinDTypeMeta Str { get; }

Property Value

LegacyBuiltinDTypeMeta

TimeDelta64

np.dtypes.TimeDelta64DType.

public static DatetimeDTypeMeta TimeDelta64 { get; }

Property Value

DatetimeDTypeMeta

UInt16

public static LegacyBuiltinDTypeMeta UInt16 { get; }

Property Value

LegacyBuiltinDTypeMeta

UInt32

public static LegacyBuiltinDTypeMeta UInt32 { get; }

Property Value

LegacyBuiltinDTypeMeta

UInt64

public static LegacyBuiltinDTypeMeta UInt64 { get; }

Property Value

LegacyBuiltinDTypeMeta

UInt8

public static LegacyBuiltinDTypeMeta UInt8 { get; }

Property Value

LegacyBuiltinDTypeMeta

Methods

AddCastingImpl(CastingImpl)

Registers a casting implementation on its source class — NumPy's PyArray_AddCastingImplementation.

public static void AddCastingImpl(CastingImpl impl)

Parameters

impl CastingImpl

FromName(string)

The class named name ("Int32DType") or one of its aliases ("IntDType"), or null.

public static DTypeMeta FromName(string name)

Parameters

name string

Returns

DTypeMeta

FromScalarType(Type)

The class of a C# scalar Type (NEP 41's np.dtype[np.float64] / NumPy's PyArray_DiscoverDTypeFromScalarType): typeof(double)Double. Array types map to their element type (np.array(int[]) is int32). Null when the type is not a NumSharp scalar.

public static DTypeMeta FromScalarType(Type type)

Parameters

type Type

Returns

DTypeMeta

FromTypeCode(NPTypeCode)

The class whose storage discriminator is typeCode; null for Empty / an unregistered code.

public static DTypeMeta FromTypeCode(NPTypeCode typeCode)

Parameters

typeCode NPTypeCode

Returns

DTypeMeta

FromTypeNum(int)

The class with NumPy type number typeNum, or null.

public static DTypeMeta FromTypeNum(int typeNum)

Parameters

typeNum int

Returns

DTypeMeta

Register(DTypeMeta)

Registers a new DType class (a user dtype). Its type number, name and aliases must be unused; a class with storage must carry an unused NPTypeCode. Casting implementations are added separately with AddCastingImpl(CastingImpl).

public static void Register(DTypeMeta meta)

Parameters

meta DTypeMeta