Fix compatibility with some astropy versions