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

Fix unittest errors on astropy >= 5.1 #124

Merged
merged 4 commits into from
Jan 10, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions specsim/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,16 @@
# 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

## 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 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.
Expand Down
2 changes: 1 addition & 1 deletion specsim/tests/test_observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions specsim/tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand All @@ -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')
Expand Down Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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'])
Expand All @@ -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)
Expand Down