'Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/88 3
Identical to test_scale_back() but uses a compressed image.'

def test_scale_back_compressed(self):

    with fits.open(self.data('scale.fits'), do_not_scale_image_data=True) as hdul:
        chdu = fits.CompImageHDU(data=hdul[0].data, header=hdul[0].header)
        chdu.writeto(self.temp('scale.fits'))
    with fits.open(self.temp('scale.fits'), mode='update', scale_back=True) as hdul:
        orig_bitpix = hdul[1].header['BITPIX']
        orig_bzero = hdul[1].header['BZERO']
        orig_bscale = hdul[1].header['BSCALE']
        orig_data = hdul[1].data.copy()
        hdul[1].data[0] = 0
    with fits.open(self.temp('scale.fits'), do_not_scale_image_data=True) as hdul:
        assert (hdul[1].header['BITPIX'] == orig_bitpix)
        assert (hdul[1].header['BZERO'] == orig_bzero)
        assert (hdul[1].header['BSCALE'] == orig_bscale)
        zero_point = int(math.floor(((- orig_bzero) / orig_bscale)))
        assert (hdul[1].data[0] == zero_point).all()
    with fits.open(self.temp('scale.fits')) as hdul:
        assert (hdul[1].data[1:] == orig_data[1:]).all()
        with fits.open(self.data('scale.fits')) as hdul2:
            hdul2[0].data[0] = 0
            assert (hdul[1].data == hdul2[0].data).all()
