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

Function get_names_flat

numpy/lib/recfunctions.py:137–166  ·  view source on GitHub ↗

Returns the field names of the input datatype as a tuple. Input datatype must have fields otherwise error is raised. Nested structure are flattened beforehand. Parameters ---------- adtype : dtype Input datatype Examples -------- >>> from numpy.lib impo

(adtype)

Source from the content-addressed store, hash-verified

135
136
137def get_names_flat(adtype):
138 """
139 Returns the field names of the input datatype as a tuple. Input datatype
140 must have fields otherwise error is raised.
141 Nested structure are flattened beforehand.
142
143 Parameters
144 ----------
145 adtype : dtype
146 Input datatype
147
148 Examples
149 --------
150 >>> from numpy.lib import recfunctions as rfn
151 >>> rfn.get_names_flat(np.empty((1,), dtype=[('A', int)]).dtype) is None
152 False
153 >>> rfn.get_names_flat(np.empty((1,), dtype=[('A',int), ('B', str)]).dtype)
154 ('A', 'B')
155 >>> adtype = np.dtype([('a', int), ('b', [('ba', int), ('bb', int)])])
156 >>> rfn.get_names_flat(adtype)
157 ('a', 'b', 'ba', 'bb')
158 """
159 listnames = []
160 names = adtype.names
161 for name in names:
162 listnames.append(name)
163 current = adtype[name]
164 if current.names is not None:
165 listnames.extend(get_names_flat(current))
166 return tuple(listnames)
167
168
169def flatten_descr(ndtype):

Callers 1

test_get_names_flatMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_get_names_flatMethod · 0.68