numpy.lib.format.dtype_to_descr#

lib.format.dtype_to_descr(dtype)[source]#

Get a serializable descriptor from the dtype.

The .descr attribute of a dtype object cannot be round-tripped through the dtype() constructor. Simple types, like dtype(‘float32’), have a descr which looks like a record array with one field with ‘’ as a name. The dtype() constructor interprets this as a request to give a default name. Instead, we construct descriptor that can be passed to dtype().

Parameters
dtypedtype

The dtype of the array that will be written to disk.

Returns
descrobject

An object that can be passed to numpy.dtype() in order to replicate the input dtype.