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

Function get_names

numpy/lib/recfunctions.py:105–134  ·  view source on GitHub ↗

Returns the field names of the input datatype as a tuple. Input datatype must have fields otherwise error is raised. Parameters ---------- adtype : dtype Input datatype Examples -------- >>> from numpy.lib import recfunctions as rfn >>> rfn.get_names(np

(adtype)

Source from the content-addressed store, hash-verified

103
104
105def get_names(adtype):
106 """
107 Returns the field names of the input datatype as a tuple. Input datatype
108 must have fields otherwise error is raised.
109
110 Parameters
111 ----------
112 adtype : dtype
113 Input datatype
114
115 Examples
116 --------
117 >>> from numpy.lib import recfunctions as rfn
118 >>> rfn.get_names(np.empty((1,), dtype=[('A', int)]).dtype)
119 ('A',)
120 >>> rfn.get_names(np.empty((1,), dtype=[('A',int), ('B', float)]).dtype)
121 ('A', 'B')
122 >>> adtype = np.dtype([('a', int), ('b', [('ba', int), ('bb', int)])])
123 >>> rfn.get_names(adtype)
124 ('a', ('b', ('ba', 'bb')))
125 """
126 listnames = []
127 names = adtype.names
128 for name in names:
129 current = adtype[name]
130 if current.names is not None:
131 listnames.append((name, tuple(get_names(current))))
132 else:
133 listnames.append(name)
134 return tuple(listnames)
135
136
137def get_names_flat(adtype):

Callers 1

test_get_namesMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_get_namesMethod · 0.68