module documentation

A place for code to be called from the implementation of np.dtype

String handling is much easier to do correctly in python.

Function __repr__ Undocumented
Function __str__ Undocumented
Function ​_byte​_order​_str Normalize byteorder to '<' or '>'
Function ​_construction​_repr No summary
Function ​_datetime​_metadata​_str Undocumented
Function ​_is​_packed Checks whether the structured data type in 'dtype' has a simple layout, where all the fields are in order, and follow each other with no alignment padding.
Function ​_isunsized Undocumented
Function ​_kind​_name Undocumented
Function ​_name​_get Undocumented
Function ​_name​_includes​_bit​_suffix Undocumented
Function ​_scalar​_str Undocumented
Function ​_struct​_dict​_str Undocumented
Function ​_struct​_list​_str Undocumented
Function ​_struct​_str Undocumented
Function ​_subarray​_str Undocumented
Function ​_unpack​_field Helper function to normalize the items in dtype.fields.
Variable ​_kind​_to​_stem Undocumented
def __repr__(dtype):

Undocumented

def __str__(dtype):

Undocumented

def _byte_order_str(dtype):
Normalize byteorder to '<' or '>'
def _construction_repr(dtype, include_align=False, short=False):

Creates a string repr of the dtype, excluding the 'dtype()' part surrounding the object. This object may be a string, a list, or a dict depending on the nature of the dtype. This is the object passed as the first parameter to the dtype constructor, and if no additional constructor parameters are given, will reproduce the exact memory layout.

Parameters

short : bool
If true, this creates a shorter repr using 'kind' and 'itemsize', instead of the longer type name.
include_align : bool

If true, this includes the 'align=True' parameter inside the struct dtype construction dict when needed. Use this flag if you want a proper repr string without the 'dtype()' part around it.

If false, this does not preserve the 'align=True' parameter or sticky NPY_ALIGNED_STRUCT flag for struct arrays like the regular repr does, because the 'align' flag is not part of first dtype constructor parameter. This mode is intended for a full 'repr', where the 'align=True' is provided as the second parameter.

def _datetime_metadata_str(dtype):

Undocumented

def _is_packed(dtype):

Checks whether the structured data type in 'dtype' has a simple layout, where all the fields are in order, and follow each other with no alignment padding.

When this returns true, the dtype can be reconstructed from a list of the field names and dtypes with no additional dtype parameters.

Duplicates the C is_dtype_struct_simple_unaligned_layout function.

def _isunsized(dtype):

Undocumented

def _kind_name(dtype):

Undocumented

def _name_get(dtype):

Undocumented

def _name_includes_bit_suffix(dtype):

Undocumented

def _scalar_str(dtype, short):

Undocumented

def _struct_dict_str(dtype, includealignedflag):

Undocumented

def _struct_list_str(dtype):

Undocumented

def _struct_str(dtype, include_align):

Undocumented

def _subarray_str(dtype):

Undocumented

def _unpack_field(dtype, offset, title=None):

Helper function to normalize the items in dtype.fields.

Call as:

dtype, offset, title = _unpack_field(*dtype.fields[name])

_kind_to_stem: dict[str, str] =

Undocumented