def stack(recs, fields=None):
if fields is None:<EOL><INDENT>fields = list(set.intersection(<EOL>*[set(rec.dtype.names) for rec in recs]))<EOL>if set(fields) == set(recs[<NUM_LIT:0>].dtype.names):<EOL><INDENT>fields = list(recs[<NUM_LIT:0>].dtype.names)<EOL><DEDENT><DEDENT>return np.hstack([rec[fields] for rec in recs])<EOL>
Stack common fields in multiple record arrays (concatenate them).

    Parameters
    ----------
    recs : list
        List of NumPy record arrays
    fields : list of strings, optional (default=None)
        The list of fields to include in the stacked array. If None, then
        include the fields in common to all the record arrays.

    Returns
    -------
    rec : NumPy record array
        The stacked array.