MCPcopy Create free account
hub / github.com/numpy/numpy / flatten_descr

Function flatten_descr

numpy/lib/recfunctions.py:169–192  ·  view source on GitHub ↗

Flatten a structured data-type description. Examples -------- >>> from numpy.lib import recfunctions as rfn >>> ndtype = np.dtype([('a', ' >> rfn.flatten_descr(ndtype) (('a', dtype('int32')), ('ba', dtype('float64')), ('bb'

(ndtype)

Source from the content-addressed store, hash-verified

167
168
169def flatten_descr(ndtype):
170 """
171 Flatten a structured data-type description.
172
173 Examples
174 --------
175 >>> from numpy.lib import recfunctions as rfn
176 >>> ndtype = np.dtype([('a', '<i4'), ('b', [('ba', '<f8'), ('bb', '<i4')])])
177 >>> rfn.flatten_descr(ndtype)
178 (('a', dtype('int32')), ('ba', dtype('float64')), ('bb', dtype('int32')))
179
180 """
181 names = ndtype.names
182 if names is None:
183 return (('', ndtype),)
184 else:
185 descr = []
186 for field in names:
187 (typ, _) = ndtype.fields[field]
188 if typ.names is not None:
189 descr.extend(flatten_descr(typ))
190 else:
191 descr.append((field, typ))
192 return tuple(descr)
193
194
195def _zip_dtype(seqarrays, flatten=False):

Callers 1

_zip_dtypeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected