From 45ae5f2d4ce4bdce26b40520e6ff916e50616db2 Mon Sep 17 00:00:00 2001 From: dylanagreen Date: Tue, 10 Jan 2023 14:09:13 -0800 Subject: [PATCH 1/4] Remove astropy.tests.plugins.display import due to function removal. --- specsim/conftest.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/specsim/conftest.py b/specsim/conftest.py index dd6cf28..61a4433 100644 --- a/specsim/conftest.py +++ b/specsim/conftest.py @@ -7,12 +7,9 @@ # With older versions of Astropy, we actually need to import the pytest # plugins themselves in order to make them discoverable by pytest. from astropy.tests.pytest_plugins import * -else: - # As of Astropy 3.0, the pytest plugins provided by Astropy are - # automatically made available when Astropy is installed. This means it's - # not necessary to import them here, but we still need to import global - # variables that are used for configuration. - from astropy.tests.plugins.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS + +# As of Astropy 5.1 astropy.tests.plugins.display (where PYTEST_HEADER_MODULES +# and TESTED_VERSIONS lived) as been deprecated and removed entirely. from astropy.tests.helper import enable_deprecations_as_exceptions @@ -20,17 +17,6 @@ ## exceptions # enable_deprecations_as_exceptions() -## Uncomment and customize the following lines to add/remove entries from -## the list of packages for which version numbers are displayed when running -## the tests. Making it pass for KeyError is essential in some cases when -## the package uses other astropy affiliated packages. -# try: -# PYTEST_HEADER_MODULES['Astropy'] = 'astropy' -# PYTEST_HEADER_MODULES['scikit-image'] = 'skimage' -# del PYTEST_HEADER_MODULES['h5py'] -# except (NameError, KeyError): # NameError is needed to support Astropy < 1.0 -# pass - ## Uncomment the following lines to display the version number of the ## package rather than the version number of Astropy in the top line when ## running the tests. From e71e34d1b96c87d0714ffc678a5347307275d414 Mon Sep 17 00:00:00 2001 From: dylanagreen Date: Tue, 10 Jan 2023 14:10:33 -0800 Subject: [PATCH 2/4] Comment out an unused import of a deprecated astropy function. --- specsim/conftest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/specsim/conftest.py b/specsim/conftest.py index 61a4433..dbdfd0c 100644 --- a/specsim/conftest.py +++ b/specsim/conftest.py @@ -11,10 +11,10 @@ # As of Astropy 5.1 astropy.tests.plugins.display (where PYTEST_HEADER_MODULES # and TESTED_VERSIONS lived) as been deprecated and removed entirely. -from astropy.tests.helper import enable_deprecations_as_exceptions - -## Uncomment the following line to treat all DeprecationWarnings as +## Uncomment the following lines to treat all DeprecationWarnings as ## exceptions +## Note that this is deprecated as of Astropy 5.1 and may be removed in the future +# from astropy.tests.helper import enable_deprecations_as_exceptions # enable_deprecations_as_exceptions() ## Uncomment the following lines to display the version number of the From da26cb2cbbbd73e6800d5954d5363f3151f5eb37 Mon Sep 17 00:00:00 2001 From: dylanagreen Date: Tue, 10 Jan 2023 14:25:40 -0800 Subject: [PATCH 3/4] Remove an unused astropy remote_data import. --- specsim/tests/test_observation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specsim/tests/test_observation.py b/specsim/tests/test_observation.py index 22a07e7..7ff53e1 100644 --- a/specsim/tests/test_observation.py +++ b/specsim/tests/test_observation.py @@ -2,7 +2,7 @@ from __future__ import absolute_import, division, print_function -from astropy.tests.helper import pytest, remote_data +from astropy.tests.helper import pytest from ..observation import * from ..instrument import initialize as instrument_init From e5f13b9b5d04831d4819026783304cc372d8e3e8 Mon Sep 17 00:00:00 2001 From: dylanagreen Date: Tue, 10 Jan 2023 14:26:18 -0800 Subject: [PATCH 4/4] Replace @remote_data with @pytest.mark.remote_data. - Also removed the astropy remote_data import. --- specsim/tests/test_transform.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/specsim/tests/test_transform.py b/specsim/tests/test_transform.py index 8669952..613dfce 100644 --- a/specsim/tests/test_transform.py +++ b/specsim/tests/test_transform.py @@ -2,7 +2,7 @@ from __future__ import absolute_import, division, print_function -from astropy.tests.helper import pytest, remote_data +from astropy.tests.helper import pytest from ..transform import altaz_to_focalplane, focalplane_to_altaz, \ observatories, create_observing_model, sky_to_altaz, altaz_to_sky, \ adjust_time_to_hour_angle, low_altitude_threshold @@ -122,7 +122,7 @@ def test_invalid_frame(): altaz_to_sky(0.5*u.rad, 1.5*u.rad, obs_model, frame='invalid') -@remote_data +@pytest.mark.remote_data def test_alt_no_warn(): where = observatories['APO'] when = Time(56383, format='mjd') @@ -136,7 +136,7 @@ def test_alt_no_warn(): altaz_to_sky(low_altitude_threshold - 1*u.deg, 0*u.deg, obs_model) -@remote_data +@pytest.mark.remote_data def test_alt_no_warn_pressure_array(): where = observatories['APO'] when = Time(56383, format='mjd') @@ -188,7 +188,7 @@ def test_alt_warn_pressure_array(): print(altaz_to_sky(alt[:, np.newaxis], 0*u.deg, obs_model).shape) -@remote_data +@pytest.mark.remote_data def test_altaz_roundtrip(): where = observatories['APO'] when = Time(56383, format='mjd') @@ -204,7 +204,7 @@ def test_altaz_roundtrip(): assert np.allclose(sky_in.dec.to(u.rad).value, sky_out.dec.to(u.rad).value) -@remote_data +@pytest.mark.remote_data def test_altaz_array_roundtrip(): where = observatories['APO'] when = Time(56383, format='mjd') @@ -220,7 +220,7 @@ def test_altaz_array_roundtrip(): assert np.all(np.abs(altaz_out.az - az_in) < 1e-5 * u.arcsec) -@remote_data +@pytest.mark.remote_data def test_sky_to_altaz_shape(): where = observatories['APO'] when = Time(56383, format='mjd') @@ -250,7 +250,7 @@ def test_sky_to_altaz_shape(): obs_model).shape == (3, 3, 2) -@remote_data +@pytest.mark.remote_data def test_altaz_to_sky_shape(): where = observatories['APO'] when = Time(56383, format='mjd') @@ -279,7 +279,7 @@ def test_altaz_to_sky_shape(): obs_model).shape == (3, 3, 2) -@remote_data +@pytest.mark.remote_data def test_adjust_null(): ra = 45 * u.deg when = Time(56383, format='mjd', location=observatories['APO']) @@ -295,14 +295,14 @@ def test_adjust_missing_longitude(): adjusted = adjust_time_to_hour_angle(when, ra, 0. * u.deg) -@remote_data +@pytest.mark.remote_data def test_adjust_future(): ra = 45 * u.deg when = Time(58000, format='mjd', location=observatories['APO']) adjusted = adjust_time_to_hour_angle(when, ra, 0. * u.deg) -@remote_data +@pytest.mark.remote_data def test_zero_hour_angle_adjust(): where = observatories['KPNO'] when = Time('2013-01-01 00:00:00', format='iso', location=where)