def rec_append_fields(rec, names, arrs, dtypes=None):
if (not cbook.is_string_like(names) and cbook.iterable(names)and len(names) and cbook.is_string_like(names[<NUM_LIT:0>])):<EOL><INDENT>if len(names) != len(arrs):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>else: <EOL><INDENT>names = [names]<EOL>arrs = [arrs]<EOL><DEDENT>arrs = list(map(np.asarray, arrs))<EOL>if dtypes is None:<EOL><INDENT>dtypes = [a.dtype for a in arrs]<EOL><DEDENT>elif not cbook.iterable(dtypes):<EOL><INDENT>dtypes = [dtypes]<EOL><DEDENT>if len(arrs) != len(dtypes):<EOL><INDENT>if len(dtypes) == <NUM_LIT:1>:<EOL><INDENT>dtypes = dtypes * len(arrs)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>newdtype = np.dtype(rec.dtype.descr + list(zip(names, dtypes)))<EOL>newrec = np.empty(rec.shape, dtype=newdtype)<EOL>for field in rec.dtype.fields:<EOL><INDENT>newrec[field] = rec[field]<EOL><DEDENT>for name, arr in zip(names, arrs):<EOL><INDENT>newrec[name] = arr<EOL><DEDENT>return rec_view(newrec)<EOL>
Return a new record array with field names populated with data
from arrays in *arrs*.  If appending a single field, then *names*,
*arrs* and *dtypes* do not have to be lists. They can just be the
values themselves.