'Regression test for https://github.com/astropy/astropy/issues/4974
BZERO/BSCALE should be removed if data is converted to a floating
point type.
Currently excluding the case where do_not_scale_image_data=True
because it is not clear what the expectation should be.'

@pytest.mark.parametrize('from_file', (False, True))
@pytest.mark.parametrize('do_not_scale', (False,))
def test_uint_header_keywords_removed_after_bitpix_change(self, from_file, do_not_scale):

    arr = np.zeros(100, dtype='uint16')
    if from_file:
        tmp_uint = fits.PrimaryHDU(arr)
        filename = 'unsigned_int.fits'
        tmp_uint.writeto(self.temp(filename))
        with fits.open(self.temp(filename), do_not_scale_image_data=do_not_scale) as f:
            uint_hdu = f[0]
            _ = uint_hdu.data
    else:
        uint_hdu = fits.PrimaryHDU(arr, do_not_scale_image_data=do_not_scale)
    assert ('BSCALE' in uint_hdu.header)
    assert ('BZERO' in uint_hdu.header)
    assert (uint_hdu.header['BSCALE'] == 1)
    assert (uint_hdu.header['BZERO'] == 32768)
    uint_hdu.data = (uint_hdu.data * 1.0)
    assert (uint_hdu.header['BITPIX'] < 0)
    assert ('BSCALE' not in uint_hdu.header)
    assert ('BZERO' not in uint_hdu.header)
    filename = 'test_uint_to_float.fits'
    uint_hdu.writeto(self.temp(filename))
    with fits.open(self.temp(filename)) as hdul:
        assert (hdul[0].data == 0).all()
