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)
| 135 | |
| 136 | |
| 137 | def 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 | |
| 169 | def flatten_descr(ndtype): |
no outgoing calls