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
Bool
public static LegacyBuiltinDTypeMeta Bool { get; }
Property Value
Char
NumSharp-only: char (type number 257, the user-defined range; promotes as uint16).
public static LegacyBuiltinDTypeMeta Char { get; }
Property Value
Complex128
public static LegacyBuiltinDTypeMeta Complex128 { get; }
Property Value
DateTime64
np.dtypes.DateTime64DType.
public static DatetimeDTypeMeta DateTime64 { get; }
Property Value
Decimal
NumSharp-only: decimal (type number 256, the user-defined range).
public static LegacyBuiltinDTypeMeta Decimal { get; }
Property Value
Double
public static LegacyBuiltinDTypeMeta Double { get; }
Property Value
Half
public static LegacyBuiltinDTypeMeta Half { get; }
Property Value
Int16
public static LegacyBuiltinDTypeMeta Int16 { get; }
Property Value
Int32
public static LegacyBuiltinDTypeMeta Int32 { get; }
Property Value
Int64
public static LegacyBuiltinDTypeMeta Int64 { get; }
Property Value
Int8
public static LegacyBuiltinDTypeMeta Int8 { get; }
Property Value
PyComplex
NEP 50's _PyComplexDType — the class of a weak C# Complex literal.
public static PyScalarDTypeMeta PyComplex { get; }
Property Value
PyFloat
NEP 50's _PyFloatDType — the class of a weak C# floating literal.
public static PyScalarDTypeMeta PyFloat { get; }
Property Value
PyLong
NEP 50's _PyLongDType — the class of a weak C# integer literal.
public static PyScalarDTypeMeta PyLong { get; }
Property Value
Single
public static LegacyBuiltinDTypeMeta Single { get; }
Property Value
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
TimeDelta64
np.dtypes.TimeDelta64DType.
public static DatetimeDTypeMeta TimeDelta64 { get; }
Property Value
UInt16
public static LegacyBuiltinDTypeMeta UInt16 { get; }
Property Value
UInt32
public static LegacyBuiltinDTypeMeta UInt32 { get; }
Property Value
UInt64
public static LegacyBuiltinDTypeMeta UInt64 { get; }
Property Value
UInt8
public static LegacyBuiltinDTypeMeta UInt8 { get; }
Property Value
Methods
AddCastingImpl(CastingImpl)
Registers a casting implementation on its source class — NumPy's PyArray_AddCastingImplementation.
public static void AddCastingImpl(CastingImpl impl)
Parameters
implCastingImpl
FromName(string)
The class named name ("Int32DType") or one of its aliases ("IntDType"), or null.
public static DTypeMeta FromName(string name)
Parameters
namestring
Returns
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
typeType
Returns
FromTypeCode(NPTypeCode)
The class whose storage discriminator is typeCode; null for Empty / an unregistered code.
public static DTypeMeta FromTypeCode(NPTypeCode typeCode)
Parameters
typeCodeNPTypeCode
Returns
FromTypeNum(int)
The class with NumPy type number typeNum, or null.
public static DTypeMeta FromTypeNum(int typeNum)
Parameters
typeNumint
Returns
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
metaDTypeMeta