Table of Contents

Enum NPY_TYPECHAR

Namespace
NumSharp
Assembly
NumSharp.dll

NumPy's NPY_TYPECHAR enum (numpy/_core/include/numpy/ndarraytypes.h, NumPy 2.4.2): the one-character type codes of the builtin dtypes (char, the strings np.dtype('d') parses) followed by the dtype KIND letters (kind). Byte-identical to the header: the same members, in the same order, with the same values, so (char)NPY_TYPECHAR.NPY_CDOUBLELTR is 'D' exactly as in C.

public enum NPY_TYPECHAR
Extension Methods

Fields

NPY_BOOLLTR = 63

'?': bool (Boolean).

NPY_BYTELTR = 98

'b': C signed char, int8 (SByte). Same value as the kind letter NPY_GENBOOLLTR.

NPY_UBYTELTR = 66

'B': C unsigned char, uint8 (Byte).

NPY_SHORTLTR = 104

'h': C short, int16 (Int16).

NPY_USHORTLTR = 72

'H': C unsigned short, uint16 (UInt16).

NPY_INTLTR = 105

'i': C int (np.intc), always 32-bit (Int32). Same value as the kind letter NPY_SIGNEDLTR.

NPY_UINTLTR = 73

'I': C unsigned int (np.uintc), always 32-bit (UInt32).

NPY_LONGLTR = 108

'l': C long (np.long): int32 on Windows, int64 on Linux and macOS.

NPY_ULONGLTR = 76

'L': C unsigned long (np.ulong): uint32 on Windows, uint64 on Linux and macOS.

NPY_LONGLONGLTR = 113

'q': C long long (np.longlong), always 64-bit (Int64).

NPY_ULONGLONGLTR = 81

'Q': C unsigned long long (np.ulonglong), always 64-bit (UInt64).

NPY_HALFLTR = 101

'e': float16 (Half).

NPY_FLOATLTR = 102

'f': float32 (Single). Same value as the kind letter NPY_FLOATINGLTR.

NPY_DOUBLELTR = 100

'd': float64 (Double).

NPY_LONGDOUBLELTR = 103

'g': C long double; NumSharp stores it as float64 (Double), Windows' form on every host.

NPY_CFLOATLTR = 70

'F': complex64. NumSharp has no complex64, so np.dtype('F') refuses it.

NPY_CDOUBLELTR = 68

'D': complex128 (Complex).

NPY_CLONGDOUBLELTR = 71

'G': C long double complex; NumSharp stores it as complex128 (Complex).

NPY_OBJECTLTR = 79

'O': object (Python objects). Not supported by NumSharp.

NPY_STRINGLTR = 83

'S': fixed-width bytes (np.bytes_, |S5). Not supported by NumSharp.

NPY_UNICODELTR = 85

'U': fixed-width Unicode (np.str_, <U5), the slot of String. Not supported by np.dtype.

NPY_VOIDLTR = 86

'V': void (raw bytes and structured records). Not supported by NumSharp.

NPY_DATETIMELTR = 77

'M': datetime64. Parses to the generic-unit descriptor, which has no NumSharp storage yet.

NPY_TIMEDELTALTR = 109

'm': timedelta64. Parses to the generic-unit descriptor, which has no NumSharp storage yet.

NPY_CHARLTR = 99

'c': NumPy's one-byte string, np.dtype('c') = S1 (np.typecodes['Character']). Not NumSharp's Char, and not complex: the complex KIND letter NPY_COMPLEXLTR shares the value.

NPY_VSTRINGLTR = 84

'T': NEP 55's variable-width StringDType - its kind and type character (np.dtype('T')).

NPY_GENBOOLLTR = 98

Kind letter 'b': booleans (np.dtype(bool).kind). Shares its value with the type character NPY_BYTELTR.

NPY_SIGNEDLTR = 105

Kind letter 'i': signed integers. Shares its value with the type character NPY_INTLTR.

NPY_UNSIGNEDLTR = 117

Kind letter 'u': unsigned integers. Not a type character: np.dtype('u') is "data type 'u' not understood".

NPY_FLOATINGLTR = 102

Kind letter 'f': floating point. Shares its value with the type character NPY_FLOATLTR.

NPY_COMPLEXLTR = 99

Kind letter 'c': complex. Shares its value with the type character NPY_CHARLTR (S1), so as a TYPE character it names bytes, not complex.

Remarks

Several members share a value, as in C, because a kind letter reuses a type character: NPY_GENBOOLLTR is NPY_BYTELTR ('b'), NPY_SIGNEDLTR is NPY_INTLTR ('i'), NPY_FLOATINGLTR is NPY_FLOATLTR ('f') and NPY_COMPLEXLTR is NPY_CHARLTR ('c'). The CHARACTER is the identity: compare values, never names. ToString() of a shared value is either name (.NET leaves the choice unspecified; on .NET 10 'b' prints NPY_GENBOOLLTR), and a switch can list only one member of each pair.

Valid type characters without a member. 'p'/'P' (pointer-sized integers) and 'n'/'N' (NumPy 2's intp/uintp, the size of size_t) are accepted by np.dtype but have no member: NumPy 2.0 removed NPY_INTPLTR/NPY_UINTPLTR when intp moved from 'p' to 'n', and defines all four explicitly in arraytypes.c.src. Cast the character to reach them: ((NPY_TYPECHAR)'n').ToTypeCode().

Platform-dependent meaning. NPY_LONGLTR/NPY_ULONGLTR name C long: 32-bit on Windows, 64-bit on Linux and macOS. So np.int32's character is 'l' on Windows and 'i' elsewhere, and np.int64's is 'q' on Windows and 'l' elsewhere; use ToTypeCode(NPY_TYPECHAR) and ToTYPECHAR(NPTypeCode) rather than fixed pairs.

A character naming a dtype NumSharp cannot store (NPY_CFLOATLTR complex64, the void kind, NPY_OBJECTLTR) is still a member, so code ported from NumPy compiles and the refusal happens where NumSharp meets the dtype (dtype(string, bool, bool, IReadOnlyDictionary<string, object>)). The string characters (NPY_STRINGLTR, NPY_UNICODELTR, NPY_CHARLTR, NPY_VSTRINGLTR) name NumSharp's own string classes. NumSharp's own Decimal and Char have no character here: NumPy has no such dtypes.