bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / lib / _iotools / flatten_dtype
function
numpy.lib._iotools:flatten_dtype
source: build-install/usr/lib/python3.14/site-packages/numpy/lib/_iotools.py:85
Signature
def flatten_dtype(ndtype, flatten_base = False)Summary
Unpack a structured data-type by collapsing nested fields and/or fields with a shape.
Extended Summary
Note that the field names are lost.
Parameters
ndtype: dtypeThe datatype to collapse
flatten_base: bool, optionalIf True, transform a field with a shape into several fields. Default is False.
Examples
import numpy as np dt = np.dtype([('name', 'S4'), ('x', float), ('y', float), ('block', int, (2, 3))]) np.lib._iotools.flatten_dtype(dt)✓
[dtype('S4'), dtype('float64'), dtype('float64'), dtype('int64')]
np.lib._iotools.flatten_dtype(dt, flatten_base=True)
✗[dtype('S4'), dtype('float64'), dtype('float64'), dtype('int64'), dtype('int64'), dtype('int64'), dtype('int64'), dtype('int64'), dtype('int64')]
Aliases
numpy.lib._iotools.flatten_dtype