'Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/84 and
https://aeon.stsci.edu/ssb/trac/pyfits/ticket/101'

def test_rewriting_large_scaled_image(self):

    hdul = fits.open(self.data('fixed-1890.fits'))
    orig_data = hdul[0].data
    with ignore_warnings():
        hdul.writeto(self.temp('test_new.fits'), overwrite=True)
    hdul.close()
    hdul = fits.open(self.temp('test_new.fits'))
    assert (hdul[0].data == orig_data).all()
    hdul.close()
    hdul = fits.open(self.data('fixed-1890.fits'))
    with ignore_warnings():
        hdul.writeto(self.temp('test_new.fits'), overwrite=True)
    hdul.close()
    hdul = fits.open(self.temp('test_new.fits'))
    assert (hdul[0].data == orig_data).all()
    hdul.close()
    hdul = fits.open(self.data('fixed-1890.fits'), do_not_scale_image_data=True)
    hdul.writeto(self.temp('test_new.fits'), overwrite=True, output_verify='silentfix')
    hdul.close()
    hdul = fits.open(self.temp('test_new.fits'))
    orig_data = hdul[0].data
    hdul.close()
    hdul = fits.open(self.temp('test_new.fits'), mode='update')
    hdul.close()
    hdul = fits.open(self.temp('test_new.fits'))
    assert (hdul[0].data == orig_data).all()
    hdul = fits.open(self.temp('test_new.fits'))
    hdul.close()
