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

Method _parseFormats

numpy/core/records.py:152–171  ·  view source on GitHub ↗

Parse the field formats

(self, formats, aligned=False)

Source from the content-addressed store, hash-verified

150 self._createdtype(byteorder)
151
152 def _parseFormats(self, formats, aligned=False):
153 """ Parse the field formats """
154
155 if formats is None:
156 raise ValueError("Need formats argument")
157 if isinstance(formats, list):
158 dtype = sb.dtype(
159 [('f{}'.format(i), format_) for i, format_ in enumerate(formats)],
160 aligned,
161 )
162 else:
163 dtype = sb.dtype(formats, aligned)
164 fields = dtype.fields
165 if fields is None:
166 dtype = sb.dtype([('f1', dtype)], aligned)
167 fields = dtype.fields
168 keys = dtype.names
169 self._f_formats = [fields[key][0] for key in keys]
170 self._offsets = [fields[key][1] for key in keys]
171 self._nfields = len(keys)
172
173 def _setfieldnames(self, names, titles):
174 """convert input field names into a list and assign to the _names

Callers 1

__init__Method · 0.95

Calls 1

dtypeMethod · 0.45

Tested by

no test coverage detected