'Regression test for https://github.com/spacetelescope/PyFITS/issues/32
Ensure that when floating point data is compressed with the
SUBTRACTIVE_DITHER_1 quantization method that the correct ZDITHER0 seed
is added to the header, and that the data can be correctly
decompressed.'

def test_subtractive_dither_seed(self):

    array = np.arange(100.0).reshape(10, 10)
    csum = ((array[0].view('uint8').sum() % 10000) + 1)
    hdu = fits.CompImageHDU(data=array, quantize_method=SUBTRACTIVE_DITHER_1, dither_seed=DITHER_SEED_CHECKSUM)
    hdu.writeto(self.temp('test.fits'))
    with fits.open(self.temp('test.fits')) as hdul:
        assert isinstance(hdul[1], fits.CompImageHDU)
        assert ('ZQUANTIZ' in hdul[1]._header)
        assert (hdul[1]._header['ZQUANTIZ'] == 'SUBTRACTIVE_DITHER_1')
        assert ('ZDITHER0' in hdul[1]._header)
        assert (hdul[1]._header['ZDITHER0'] == csum)
        assert np.all((hdul[1].data == array))
