def test_comphdu_bscale(tmpdir):
 filename1 = tmpdir.join('3hdus.fits').strpath
 filename2 = tmpdir.join('3hdus_comp.fits').strpath
 x = (np.random.random((100, 100)) * 100)
 x0 = fits.PrimaryHDU()
 x1 = fits.ImageHDU(np.array((x - 50), dtype=int), uint=True)
 x1.header['BZERO'] = 20331
 x1.header['BSCALE'] = 2.3
 hdus = fits.HDUList([x0, x1])
 hdus.writeto(filename1)
 hdus = fits.open(filename1)
 hdus[1] = fits.CompImageHDU(data=hdus[1].data.astype(np.uint32), header=hdus[1].header)
 hdus.writeto(filename2)
 hdus = fits.open(filename2)
 hdus[1].verify('exception')

def test_comphdu_bscale ( tmpdir ) : filename1 = tmpdir . join ( '3hdus.fits' ) . strpath filename2 = tmpdir . join ( '3hdus_comp.fits' ) . strpath x = ( np . random . random ( ( 100 , 100 ) ) * 100 ) x0 = fits . PrimaryHDU ( ) x1 = fits . ImageHDU ( np . array ( ( x - 50 ) , dtype = int ) , uint = True ) x1 . header [ 'BZERO' ] = 20331 x1 . header [ 'BSCALE' ] = 2.3 hdus = fits . HDUList ( [ x0 , x1 ] ) hdus . writeto ( filename1 ) hdus = fits . open ( filename1 ) hdus [ 1 ] = fits . CompImageHDU ( data = hdus [ 1 ] . data . astype ( np . uint32 ) , header = hdus [ 1 ] . header ) hdus . writeto ( filename2 ) hdus = fits . open ( filename2 ) hdus [ 1 ] . verify ( 'exception' )
regression test for a bug that caused extensions that used bzero and bscale that got turned into compimagehdu to end up with bzero/bscale before the tfields .