From 0a722fd1eba098784009e52b7f19c096ba417c09 Mon Sep 17 00:00:00 2001 From: "Nathaniel Starkman (@nstarman)" Date: Sat, 6 May 2023 21:55:14 -0400 Subject: [PATCH 1/2] remove deprecated import path Signed-off-by: Nathaniel Starkman (@nstarman) --- astropy/cosmology/core.py | 23 ----------------------- astropy/cosmology/tests/test_core.py | 22 ---------------------- 2 files changed, 45 deletions(-) diff --git a/astropy/cosmology/core.py b/astropy/cosmology/core.py index c6c8ad2acaa..3036dc40d2e 100644 --- a/astropy/cosmology/core.py +++ b/astropy/cosmology/core.py @@ -589,26 +589,3 @@ def __equiv__(self, other): ) return params_eq - - -# ----------------------------------------------------------------------------- - - -def __getattr__(attr): - from . import flrw - - if hasattr(flrw, attr) and attr not in ("__path__",): - import warnings - - from astropy.utils.exceptions import AstropyDeprecationWarning - - warnings.warn( - f"`astropy.cosmology.core.{attr}` has been moved (since v5.0) and " - f"should be imported as ``from astropy.cosmology import {attr}``." - " In future this will raise an exception.", - AstropyDeprecationWarning, - ) - - return getattr(flrw, attr) - - raise AttributeError(f"module {__name__!r} has no attribute {attr!r}.") diff --git a/astropy/cosmology/tests/test_core.py b/astropy/cosmology/tests/test_core.py index cc8c6edb3f4..ba4c6ad19c8 100644 --- a/astropy/cosmology/tests/test_core.py +++ b/astropy/cosmology/tests/test_core.py @@ -2,19 +2,13 @@ """Testing :mod:`astropy.cosmology.core`.""" -############################################################################## -# IMPORTS - -# STDLIB import abc import inspect import pickle -# THIRD PARTY import numpy as np import pytest -# LOCAL import astropy.cosmology.units as cu import astropy.units as u from astropy.cosmology import Cosmology, FlatCosmologyMixin @@ -22,7 +16,6 @@ from astropy.cosmology.parameter import Parameter from astropy.table import Column, QTable, Table from astropy.utils.compat import PYTHON_LT_3_11 -from astropy.utils.exceptions import AstropyDeprecationWarning from astropy.utils.metadata import MetaData from .test_connect import ReadWriteTestMixin, ToFromFormatTestMixin @@ -537,18 +530,3 @@ class FlatSubCosmology(FlatCosmologyMixin, SubCosmology, SubCosmology2): @property def nonflat(self): pass - - -# ----------------------------------------------------------------------------- - - -def test_flrw_moved_deprecation(): - """Test the deprecation warning about the move of FLRW classes.""" - from astropy.cosmology import flrw - - # it's deprecated to import `flrw/*` from `core.py` - with pytest.warns(AstropyDeprecationWarning): - from astropy.cosmology.core import FLRW - - # but they are the same object - assert FLRW is flrw.FLRW From 7598308d80799bf6b889e3b87433b694970d579f Mon Sep 17 00:00:00 2001 From: "Nathaniel Starkman (@nstarman)" Date: Sat, 6 May 2023 22:00:16 -0400 Subject: [PATCH 2/2] changelog Signed-off-by: Nathaniel Starkman (@nstarman) --- docs/changes/cosmology/14782.api.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/changes/cosmology/14782.api.rst diff --git a/docs/changes/cosmology/14782.api.rst b/docs/changes/cosmology/14782.api.rst new file mode 100644 index 00000000000..46c33f89e72 --- /dev/null +++ b/docs/changes/cosmology/14782.api.rst @@ -0,0 +1 @@ +Removed deprecated import paths from ``astropy.cosmology.core``.