def _checknames(descr, names=None):
ndescr = len(descr)<EOL>default_names = ['<STR_LIT>' % i for i in range(ndescr)]<EOL>if names is None:<EOL><INDENT>new_names = default_names<EOL><DEDENT>else:<EOL><INDENT>if isinstance(names, (tuple, list)):<EOL><INDENT>new_names = names<EOL><DEDENT>elif isinstance(names, str):<EOL><INDENT>new_names = names.split('<STR_LIT:U+002C>')<EOL><DEDENT>else:<EOL><INDENT>raise NameError("<STR_LIT>" % repr(names))<EOL><DEDENT>nnames = len(new_names)<EOL>if nnames < ndescr:<EOL><INDENT>new_names += default_names[nnames:]<EOL><DEDENT><DEDENT>ndescr = []<EOL>for (n, d, t) in zip(new_names, default_names, descr.descr):<EOL><INDENT>if n in reserved_fields:<EOL><INDENT>if t[<NUM_LIT:0>] in reserved_fields:<EOL><INDENT>ndescr.append((d, t[<NUM_LIT:1>]))<EOL><DEDENT>else:<EOL><INDENT>ndescr.append(t)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>ndescr.append((n, t[<NUM_LIT:1>]))<EOL><DEDENT><DEDENT>return np.dtype(ndescr)<EOL>
Checks that the field names of the descriptor ``descr`` are not some
reserved keywords. If this is the case, a default 'f%i' is substituted.
If the argument `names` is not None, updates the field names to valid names.