#NEWLINE# def test_scaled_data_auto_rescale( self ) : #NEWLINE# #INDENT# '\n        Regression test for\n        https://github.com/astropy/astropy/issues/3883#issuecomment-115122647\n\n        Ensure that when scaled data is automatically rescaled on\n        opening/writing a file that the checksum and datasum are computed for\n        the rescaled array.\n        ' #NEWLINE# with fits . open ( self . data ( 'scale.fits' ) ) as hdul : #NEWLINE# #INDENT# hdul . writeto ( self . temp ( 'rescaled.fits' ) ) #NEWLINE# #UNINDENT# with fits . open ( self . temp ( 'rescaled.fits' ) ) as hdul : #NEWLINE# #INDENT# hdul . writeto ( self . temp ( 'rescaled2.fits' ) , clobber = True , checksum = True ) #NEWLINE# #UNINDENT# with fits . open ( self . data ( 'scale.fits' ) ) as hdul : #NEWLINE# #INDENT# hdul . writeto ( self . temp ( 'rescaled3.fits' ) , checksum = True ) #NEWLINE# #UNINDENT# with fits . open ( self . data ( 'scale.fits' ) , do_not_scale_image_data = True ) as hdul : #NEWLINE# #INDENT# hdul . writeto ( self . temp ( 'scaled.fits' ) , checksum = True ) #NEWLINE# #UNINDENT# with fits . open ( self . temp ( 'rescaled2.fits' ) ) as hdul1 : #NEWLINE# #INDENT# with fits . open ( self . temp ( 'rescaled3.fits' ) ) as hdul2 : #NEWLINE# #INDENT# with fits . open ( self . temp ( 'scaled.fits' ) ) as hdul3 : #NEWLINE# #INDENT# hdr1 = hdul1 [ 0 ] . header #NEWLINE# hdr2 = hdul2 [ 0 ] . header #NEWLINE# hdr3 = hdul3 [ 0 ] . header #NEWLINE# assert ( hdr1 [ 'DATASUM' ] == hdr2 [ 'DATASUM' ] ) #NEWLINE# assert ( hdul3 [ 'CHECKSUM' ] == hdr2 [ 'CHECKSUM' ] ) #NEWLINE# assert ( hdr1 [ 'DATASUM' ] != hdr3 [ 'DATASUM' ] ) #NEWLINE# assert ( hdr1 [ 'CHECKSUM' ] != hdr3 [ 'CHECKSUM' ] )