Skip to content

Upgrading astropy 6 to 7

Breaking6.1.7 → 7.2.3Breaking24Platform1Deprecated26New94Changed72Fixed112Other3

BreakingUpgrade verdict

24 breaking changes and a platform requirement change.

  • Interactive tables in the browser now load their JavaScript from the internet instead of from files shipped with Astropy, so they may not work offline.
  • The old get_moon() helper is gone; call get_body with "moon" instead.
  • The old get_frame_attr_names() method is removed; use get_frame_attr_defaults().
  • Code that imported helpers from astropy.cosmology.utils must now import them from astropy.cosmology.
Top 5 of 51 that need code or config changes

Python requirement changed in 7.0.0rc1: >=3.10 → >=3.11.

Breaking24
Removes bundled jQuery and DataTables; show_in_browser now uses remote DataTables 2.1.8 and ignores use_local_files=True with a warning.
show_in_browseruse_local_files
Removes the deprecated coordinates.get_moon() function; use coordinates.get_body("moon") instead.
coordinates.get_moon()coordinates.get_body()
Removes the deprecated BaseCoordinateFrame.get_frame_attr_names(); use get_frame_attr_defaults() instead.
BaseCoordinateFrame.get_frame_attr_names()get_frame_attr_defaults()
Removes the deprecated cosmology.utils module; import public API directly from cosmology instead.
cosmology.utilscosmology
Removes all deprecated arguments from astropy.io.ascii read, get_reader, write and get_writer.
astropy.io.ascii.read()astropy.io.ascii.get_reader()astropy.io.ascii.write()astropy.io.ascii.get_writer()ReaderInputterOutputterWriter
Refactors CompImageHDU to inherit from ImageHDU instead of BinTableHDU and defaults uint to True.
CompImageHDUImageHDUBinTableHDUuint
Removes many unintended exports from astropy.io.fits.hdu.compressed, moving low-level functions to qualified names.
astropy.io.fits.hdu.compressedcompress_image_datadecompress_image_data_sectionastropy.io.fits.hdu.compressed._tiled_compression.compress_image_dataastropy.io.fits.hdu.compressed._tiled_compression.decompress_image_data_section
Removes previously deprecated _ExtensionHDU, _NonstandardExtHDU, (Bin)Table.update and tile_size, and invalid tile_shape now raises.
_ExtensionHDU_NonstandardExtHDUTable.updateBinTable.updatetile_sizetile_shapeCompImageHDU
Removes the deprecated comb() function; use math.comb() instead.
comb()math.comb()
Removes the deprecated Quantity.nansum() method; use np.nansum instead.
Quantity.nansum()np.nansum
Removes the deprecated units.format.Unscaled; use units.format.Generic instead.
units.format.Unscaledunits.format.Generic
Removes the deprecated compat.override__dir__() utility.
compat.override__dir__()
Removes deprecated exp attributes from LogStretch, InvertedLogStretch, PowerDistStretch, InvertedPowerDistStretch and power from PowerStretch.
LogStretchInvertedLogStretchPowerDistStretchInvertedPowerDistStretchPowerStretchexppowera
Removes the unintended NumPy export previously at astropy.visualization.np.
astropy.visualization.np
Removes the deprecated nsamples parameter of ZScaleInterval.
ZScaleIntervalnsamples
OGIP unit parser no longer accepts a component unit followed by a parenthesized unit without a separator, such as 'm(s)'.
Cosmology methods now exclusively return arrays, not floats or other scalars.
Removes the undocumented earth_orientation module.
earth_orientation
EarthLocation.of_site() now raises an error instead of falling back to a bundled Greenwich data file when no cache or download is available.
EarthLocation.of_site()
Removes astropy.tests.runner.keyword from the public API.
astropy.tests.runner.keyword
len(frame) now returns the first element of shape for non-scalar frames without data, and raises TypeError for scalar frames.
len(frame)shape
Subclasses of _NonLinearLSQFitter must accept a fit_param_indices kwarg in objective_function.
_NonLinearLSQFitterLevMarLSQFitterTRFLSQFitterLMLSQFitterDogBoxLSQFitterobjective_functionfit_param_indicesfitter_to_model_params_array
Changes Base.format_exponential_notation(); custom formatters inheriting directly from Base must implement or call format() instead.
Base.format_exponential_notation()format()
OGIP unit parser now rejects negative powers not enclosed in parentheses, e.g. 's**-1'.
u.Unit()parse_strict
Platform1
Updates minimum supported Python to 3.11 and requires numpy>=1.23.2, PyYAML>=6.0.0, and packaging>=22.0.0.
Deprecated26
Deprecates astropy.coordinates.concatenate and concatenate_representations in favor of np.concatenate.
astropy.coordinates.concatenateastropy.coordinates.concatenate_representationsnp.concatenate
Deprecates selecting a table index via .loc, .iloc, or .loc_indices by passing the index identifier first, planned for removal in astropy 9.0.
.loc.iloc.loc_indiceswith_index()
Pending deprecation of astropy.test, astropy.tests.runner.TestRunnerBase, and astropy.tests.runner.TestRunner.
astropy.testastropy.tests.runner.TestRunnerBaseastropy.tests.runner.TestRunnerAstropyPendingDeprecationWarningAstropyDeprecationWarning
Deprecates the isiterable() utility; numpy.iterable() can be used as a drop-in replacement.
isiterable()numpy.iterable()
Emits a deprecation warning for each invalid axis name in set_ticklabel_position, set_axislabel_position, and set_ticks_position.
set_ticklabel_positionset_axislabel_positionset_ticks_position
Emits a deprecation warning when arguments are given to get_axislabel_visibility_rule.
get_axislabel_visibility_rule
Deprecates the get_name method on representations in favor of the class-level attribute name.
get_namename
Deprecates private cosmology modules funcs, parameter, connect, core, and flrw; functionality remains in astropy.cosmology or astropy.cosmology.io.
astropy.cosmology.funcsastropy.cosmology.parameterastropy.cosmology.connectastropy.cosmology.coreastropy.cosmology.flrwastropy.cosmologyastropy.cosmology.io
Deprecates the showtable CLI to avoid a Debian name clash; use showtable-astropy instead.
showtableshowtable-astropy
Deprecates automatic conversion of str or bytes to a unit when multiplied or divided with a unit or quantity.
Accessing contents of the units.deprecated module now emits deprecation warnings and the module may be removed.
units.deprecated
Marks all simple_norm arguments except data and stretch as future keyword-only, warning on positional use.
simple_normdatastretch
Deprecates the use_local_files keyword for the js viewer in Table.show_in_browser; from 7.1 it will be ignored and warn.
use_local_filesastropy.table.Table.show_in_browser
Deprecates passing redshift arguments as keywords in many cosmology methods.
Deprecates setting Ob0 = None in FLRW cosmologies in favor of Ob0 = 0.0.
Ob0
Deprecates CompImageHeader; CompImageHDU headers are now plain Header instances.
CompImageHeaderCompImageHDUCompImageHDU.headerHeader
Deprecates using LMLSQFitter with models that have bounds.
LMLSQFitter
Deprecates the use_min_max_bounds keyword argument in TRFLSQFitter and DogBoxLSQFitter.
use_min_max_boundsTRFLSQFitterDogBoxLSQFitter
Deprecates the factor parameter of the spectral_density equivalency; use the wav parameter as a Quantity.
spectral_densityfactorwavQuantity
Renames the format.Fits formatter class to format.FITS and deprecates the old name.
format.Fitsformat.FITSQuantityUnitBase
Deprecates NamedUnit.get_format_name() and its subclasses; use to_string() instead.
NamedUnit.get_format_name()NamedUnit.to_string()
Deprecates UnitBase.in_units(); use to() as a drop-in replacement.
UnitBase.in_units()UnitBase.to()
Deprecates astropy.utils.check_broadcast in favor of numpy.broadcast_shapes.
astropy.utils.check_broadcastnumpy.broadcast_shapes
Deprecates introspection.resolve_name() in favor of the standard library importlib.
introspection.resolve_name()importlib
Deprecates format_exception() because it offers little benefit over normal Python tracebacks.
format_exception()
Deprecates accessing or setting ticks, ticklabels and axislabels on CoordinateHelper, and setting several other attributes directly.
CoordinateHelperticksticklabelsaxislabelsset_coord_typecoord_typecoord_wrapminor_frequency