Returns whether one or several fields of a dtype are nested. Parameters ---------- ndtype : dtype Data-type of a structured array. Raises ------ AttributeError If `ndtype` does not have a `names` attribute. Examples -------- >>> dt = np.dty
(ndtype)
| 57 | |
| 58 | |
| 59 | def has_nested_fields(ndtype): |
| 60 | """ |
| 61 | Returns whether one or several fields of a dtype are nested. |
| 62 | |
| 63 | Parameters |
| 64 | ---------- |
| 65 | ndtype : dtype |
| 66 | Data-type of a structured array. |
| 67 | |
| 68 | Raises |
| 69 | ------ |
| 70 | AttributeError |
| 71 | If `ndtype` does not have a `names` attribute. |
| 72 | |
| 73 | Examples |
| 74 | -------- |
| 75 | >>> dt = np.dtype([('name', 'S4'), ('x', float), ('y', float)]) |
| 76 | >>> np.lib._iotools.has_nested_fields(dt) |
| 77 | False |
| 78 | |
| 79 | """ |
| 80 | for name in ndtype.names or (): |
| 81 | if ndtype[name].names is not None: |
| 82 | return True |
| 83 | return False |
| 84 | |
| 85 | |
| 86 | def flatten_dtype(ndtype, flatten_base=False): |
no outgoing calls