@@ -239,6 +239,8 @@ def test_open_scaled_in_update_mode_compressed(self):
239239 # it
240240 with fits .open (self .data ("scale.fits" ), do_not_scale_image_data = True ) as hdul :
241241 chdu = fits .CompImageHDU (data = hdul [0 ].data , header = hdul [0 ].header )
242+ chdu .header ["BZERO" ] = hdul [0 ].header ["BZERO" ]
243+ chdu .header ["BSCALE" ] = hdul [0 ].header ["BSCALE" ]
242244 chdu .writeto (self .temp ("scale.fits" ))
243245 mtime = os .stat (self .temp ("scale.fits" )).st_mtime
244246
@@ -354,6 +356,8 @@ def test_scale_back_compressed(self):
354356 # Create a compressed version of the scaled image
355357 with fits .open (self .data ("scale.fits" ), do_not_scale_image_data = True ) as hdul :
356358 chdu = fits .CompImageHDU (data = hdul [0 ].data , header = hdul [0 ].header )
359+ chdu .header ["BZERO" ] = hdul [0 ].header ["BZERO" ]
360+ chdu .header ["BSCALE" ] = hdul [0 ].header ["BSCALE" ]
357361 chdu .writeto (self .temp ("scale.fits" ))
358362
359363 with fits .open (self .temp ("scale.fits" ), mode = "update" , scale_back = True ) as hdul :
@@ -1005,11 +1009,11 @@ def setup_method(self, tmp_path):
10051009 )
10061010
10071011 header2 = fits .Header ()
1008- header2 ["BSCALE" ] = 2
1009- header2 ["BZERO" ] = 100
10101012 hdu2 = fits .CompImageHDU (
10111013 self .data , header2 , compression_type = "RICE_1" , tile_shape = (5 , 4 , 5 )
10121014 )
1015+ hdu2 .header ["BSCALE" ] = 2
1016+ hdu2 .header ["BZERO" ] = 100
10131017 hdulist = fits .HDUList ([fits .PrimaryHDU (), hdu1 , hdu2 ])
10141018 hdulist .writeto (tmp_path / "sections.fits" )
10151019
@@ -1126,7 +1130,6 @@ def test_uint_option(tmp_path):
11261130 assert_allclose (hdulist [1 ].data , data )
11271131
11281132
1129- @pytest .mark .xfail
11301133def test_incorrect_bzero (tmp_path ):
11311134 """
11321135 Regression test for https://github.com/astropy/astropy/issues/5999 which is
@@ -1158,6 +1161,7 @@ def test_incorrect_bzero(tmp_path):
11581161 for hdu in hdulist_read :
11591162 assert hdu .header .get ("BZERO" ) is None
11601163 assert hdu .header .get ("BSCALE" ) is None
1164+ np .testing .assert_array_equal (hdulist_read [1 ].data , hdulist_read [2 ].data )
11611165
11621166
11631167def test_custom_extname ():
0 commit comments