Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove deprecated import path #14782

Merged
merged 2 commits into from May 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 0 additions & 23 deletions astropy/cosmology/core.py
Expand Up @@ -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}.")
22 changes: 0 additions & 22 deletions astropy/cosmology/tests/test_core.py
Expand Up @@ -2,27 +2,20 @@

"""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
from astropy.cosmology.core import _COSMOLOGY_CLASSES
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
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions docs/changes/cosmology/14782.api.rst
@@ -0,0 +1 @@
Removed deprecated import paths from ``astropy.cosmology.core``.