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

Function has_nested_fields

numpy/lib/_iotools.py:59–83  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

57
58
59def 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
86def flatten_dtype(ndtype, flatten_base=False):

Callers 2

test_has_nested_dtypeMethod · 0.90
genfromtxtFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_has_nested_dtypeMethod · 0.72