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 -------- >>> import nump
(ndtype)
| 58 | |
| 59 | |
| 60 | def has_nested_fields(ndtype): |
| 61 | """ |
| 62 | Returns whether one or several fields of a dtype are nested. |
| 63 | |
| 64 | Parameters |
| 65 | ---------- |
| 66 | ndtype : dtype |
| 67 | Data-type of a structured array. |
| 68 | |
| 69 | Raises |
| 70 | ------ |
| 71 | AttributeError |
| 72 | If `ndtype` does not have a `names` attribute. |
| 73 | |
| 74 | Examples |
| 75 | -------- |
| 76 | >>> import numpy as np |
| 77 | >>> dt = np.dtype([('name', 'S4'), ('x', float), ('y', float)]) |
| 78 | >>> np.lib._iotools.has_nested_fields(dt) |
| 79 | False |
| 80 | |
| 81 | """ |
| 82 | return any(ndtype[name].names is not None for name in ndtype.names or ()) |
| 83 | |
| 84 | |
| 85 | def flatten_dtype(ndtype, flatten_base=False): |
searching dependent graphs…