Table of Contents

Class np.dtypes

Namespace
NumSharp
Assembly
NumSharp.dll

numpy.dtypes (NEP 56 / NumPy 1.25+): the DType CLASSES — np.dtypes.Float64DType is type(np.dtype('f8')). Each member is the live DTypeMeta singleton; its Instantiate() is NumPy's class call (Int8DType() → dtype('int8'); DateTime64DType() raises the "Preliminary-API … can only be instantiated using np.dtype(...)" TypeError), and Meta is type(dtype).

[ModuleName("np.dtypes")]
public static class np.dtypes
Inheritance
np.dtypes
Inherited Members

Remarks

Names and aliases are NumPy 2.4.2's numpy.dtypes.all: ByteDType/UByteDType for int8/uint8, ShortDType/UShortDType for int16/uint16, IntDType/UIntDType for int32/uint32, LongLongDType/ULongLongDType for int64/uint64, and the platform-dependent LongDType/ULongDType (C long: 32-bit on Windows and 32-bit hosts, 64-bit on LP64 Unix). LongDoubleDType and CLongDoubleDType alias the 64-bit float / complex classes — NumSharp has no extended precision, exactly as NumPy's win-amd64 build. StrDType and BytesDType are the fixed-width string classes (StringDTypeMeta). StringDType (NEP 55) is NumPy's one class you CALL with keyword parameters; C# cannot make a member both a class and a call, so it is the pair of factory methods StringDType(bool) / StringDType(object, bool), and the class itself is VString (type(dt) is Meta). The classes NumPy has and NumSharp does not (Complex64DType, ObjectDType, VoidDType) are absent rather than stubbed; DecimalDType and CharDType are NumSharp-only.

Properties

BoolDType

numpy.dtypes.BoolDType.

public static LegacyBuiltinDTypeMeta BoolDType { get; }

Property Value

LegacyBuiltinDTypeMeta

ByteDType

numpy.dtypes.ByteDType — alias of Int8DType.

public static LegacyBuiltinDTypeMeta ByteDType { get; }

Property Value

LegacyBuiltinDTypeMeta

BytesDType

numpy.dtypes.BytesDType — fixed-width bytes (S), parametric in the length: BytesDType.Instantiate(3) is NumPy's BytesDType(3) → dtype('S3').

public static StringDTypeMeta BytesDType { get; }

Property Value

StringDTypeMeta

CLongDoubleDType

numpy.dtypes.CLongDoubleDType — the complex long double class, sharing Complex128DType's storage lane (two 8-byte parts).

public static LegacyBuiltinDTypeMeta CLongDoubleDType { get; }

Property Value

LegacyBuiltinDTypeMeta

CharDType

NumSharp-only: the char class (no NumPy analog; promotes as uint16; type number 257).

public static LegacyBuiltinDTypeMeta CharDType { get; }

Property Value

LegacyBuiltinDTypeMeta

Complex128DType

numpy.dtypes.Complex128DType.

public static LegacyBuiltinDTypeMeta Complex128DType { get; }

Property Value

LegacyBuiltinDTypeMeta

DateTime64DType

numpy.dtypes.DateTime64DType — parametric; descriptor-level in Stage A.

public static DatetimeDTypeMeta DateTime64DType { get; }

Property Value

DatetimeDTypeMeta

DecimalDType

NumSharp-only: the decimal class (no NumPy analog; type number 256, isbuiltin == 2).

public static LegacyBuiltinDTypeMeta DecimalDType { get; }

Property Value

LegacyBuiltinDTypeMeta

Float16DType

numpy.dtypes.Float16DType.

public static LegacyBuiltinDTypeMeta Float16DType { get; }

Property Value

LegacyBuiltinDTypeMeta

Float32DType

numpy.dtypes.Float32DType.

public static LegacyBuiltinDTypeMeta Float32DType { get; }

Property Value

LegacyBuiltinDTypeMeta

Float64DType

numpy.dtypes.Float64DType.

public static LegacyBuiltinDTypeMeta Float64DType { get; }

Property Value

LegacyBuiltinDTypeMeta

Int16DType

numpy.dtypes.Int16DType.

public static LegacyBuiltinDTypeMeta Int16DType { get; }

Property Value

LegacyBuiltinDTypeMeta

Int32DType

numpy.dtypes.Int32DType.

public static LegacyBuiltinDTypeMeta Int32DType { get; }

Property Value

LegacyBuiltinDTypeMeta

Int64DType

numpy.dtypes.Int64DType.

public static LegacyBuiltinDTypeMeta Int64DType { get; }

Property Value

LegacyBuiltinDTypeMeta

Int8DType

numpy.dtypes.Int8DType.

public static LegacyBuiltinDTypeMeta Int8DType { get; }

Property Value

LegacyBuiltinDTypeMeta

IntDType

numpy.dtypes.IntDType (C int): on Windows a class of its own beside Int32DType (which is the C long there), sharing int32's storage lane; on Linux and macOS an alias of Int32DType.

public static LegacyBuiltinDTypeMeta IntDType { get; }

Property Value

LegacyBuiltinDTypeMeta

LongDType

numpy.dtypes.LongDType (C long): Int32DType on Windows / 32-bit hosts, Int64DType on LP64 Unix.

public static LegacyBuiltinDTypeMeta LongDType { get; }

Property Value

LegacyBuiltinDTypeMeta

LongDoubleDType

numpy.dtypes.LongDoubleDType — NumPy's C long double class, a class of its own sharing Float64DType's storage lane: 8 bytes on every platform (NumSharp has no extended precision, as on NumPy's win-amd64 build), its descriptors equal to float64's.

public static LegacyBuiltinDTypeMeta LongDoubleDType { get; }

Property Value

LegacyBuiltinDTypeMeta

LongLongDType

numpy.dtypes.LongLongDType (C long long): on Linux and macOS a class of its own beside Int64DType (which is the C long there), sharing int64's storage lane; on Windows an alias of Int64DType.

public static LegacyBuiltinDTypeMeta LongLongDType { get; }

Property Value

LegacyBuiltinDTypeMeta

ShortDType

numpy.dtypes.ShortDType — alias of Int16DType.

public static LegacyBuiltinDTypeMeta ShortDType { get; }

Property Value

LegacyBuiltinDTypeMeta

StrDType

numpy.dtypes.StrDType — fixed-width Unicode (U), parametric in the length: StrDType.Instantiate(5) is NumPy's StrDType(5) → dtype('<U5').

public static StringDTypeMeta StrDType { get; }

Property Value

StringDTypeMeta

TimeDelta64DType

numpy.dtypes.TimeDelta64DType — parametric; descriptor-level in Stage A.

public static DatetimeDTypeMeta TimeDelta64DType { get; }

Property Value

DatetimeDTypeMeta

UByteDType

numpy.dtypes.UByteDType — alias of UInt8DType.

public static LegacyBuiltinDTypeMeta UByteDType { get; }

Property Value

LegacyBuiltinDTypeMeta

UInt16DType

numpy.dtypes.UInt16DType.

public static LegacyBuiltinDTypeMeta UInt16DType { get; }

Property Value

LegacyBuiltinDTypeMeta

UInt32DType

numpy.dtypes.UInt32DType.

public static LegacyBuiltinDTypeMeta UInt32DType { get; }

Property Value

LegacyBuiltinDTypeMeta

UInt64DType

numpy.dtypes.UInt64DType.

public static LegacyBuiltinDTypeMeta UInt64DType { get; }

Property Value

LegacyBuiltinDTypeMeta

UInt8DType

numpy.dtypes.UInt8DType.

public static LegacyBuiltinDTypeMeta UInt8DType { get; }

Property Value

LegacyBuiltinDTypeMeta

UIntDType

numpy.dtypes.UIntDType (C unsigned int): its own class on Windows, an alias of UInt32DType elsewhere (see IntDType).

public static LegacyBuiltinDTypeMeta UIntDType { get; }

Property Value

LegacyBuiltinDTypeMeta

ULongDType

numpy.dtypes.ULongDType (C unsigned long): UInt32DType on Windows / 32-bit hosts, UInt64DType on LP64 Unix.

public static LegacyBuiltinDTypeMeta ULongDType { get; }

Property Value

LegacyBuiltinDTypeMeta

ULongLongDType

numpy.dtypes.ULongLongDType (C unsigned long long): its own class on Linux and macOS, an alias of UInt64DType on Windows (see LongLongDType).

public static LegacyBuiltinDTypeMeta ULongLongDType { get; }

Property Value

LegacyBuiltinDTypeMeta

UShortDType

numpy.dtypes.UShortDType — alias of UInt16DType.

public static LegacyBuiltinDTypeMeta UShortDType { get; }

Property Value

LegacyBuiltinDTypeMeta

Methods

StringDType(bool)

np.dtypes.StringDType(coerce=True): a NEW variable-width string descriptor without a missing-data object. Every call returns a fresh descriptor (NumPy's StringDType() is StringDType() is False), equal to any other with the same parameters.

public static DType StringDType(bool coerce = true)

Parameters

coerce bool

NumPy's coerce: true (the default) stores a value that is not a str as its str() (3.25 → '3.25'); false refuses it with NumPy's ValueError: StringDType only allows string data when string coercion is disabled.

Returns

DType

A fresh descriptor: StringDType() or StringDType(coerce=False).

Remarks

The overload without na_object keeps NumPy's "not given" apart from na_object=None: StringDType() has no missing-data object at all, while StringDType(na_object: null) has None as its sentinel.

StringDType(object, bool)

np.dtypes.StringDType(na_object=…, coerce=True): a NEW variable-width string descriptor with a missing-data sentinel.

public static DType StringDType(object na_object, bool coerce = true)

Parameters

na_object object

The sentinel: null is Python's None; a double / float NaN is nan (NaN-like: StringDType(na_object=nan) equals StringDType(na_object=np.nan)); a string (or a char) is a string sentinel, which missing values read as in string operations; any other value is an "other" sentinel compared with Python's == (numbers by value).

coerce bool

NumPy's coerce (see StringDType(bool)).

Returns

DType

A fresh descriptor, printing as StringDType(na_object=None), StringDType(na_object='NA', coerce=False), …

Remarks

Pass a bool sentinel BY NAME (StringDType(na_object: true)): a positional bool binds the StringDType(bool) overload and means coerce.

Exceptions

UnicodeEncodeError

A string sentinel (or the str() of another sentinel) holds a lone surrogate: NumPy stores it as UTF-8 and raises CPython's 'utf-8' codec can't encode character '\ud800' in position 0: surrogates not allowed.

ValueError

The sentinel is a Python int (BigInteger) of more than 4300 decimal digits: NumPy takes its str() while building the descriptor and CPython refuses it, Exceeds the limit (4300 digits) for integer string conversion; use sys.set_int_max_str_digits() to increase the limit.