'Tests creating a `FITS_rec` object with `FITS_rec.from_columns`
from an existing `FITS_rec` object read from a FITS file.
This ensures that the per-column arrays are updated properly.
Regression test for https://github.com/spacetelescope/PyFITS/issues/99'

def test_fits_rec_from_existing(self):

    data1 = fits.getdata(self.data('tb.fits'))
    data2 = fits.getdata(self.data('tb.fits'))
    nrows = (len(data1) + len(data2))
    merged = fits.FITS_rec.from_columns(data1, nrows=nrows)
    merged[len(data1):] = data2
    mask = (merged['c1'] > 1)
    masked = merged[mask]
    assert comparerecords(data1[1:], masked[:1])
    assert comparerecords(data1[1:], masked[1:])
    assert comparerecords(data1, fits.getdata(self.data('tb.fits')))
