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

BUG: better handling the optional dependency required for functionality #3039

Merged
merged 2 commits into from
Jun 14, 2024
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
1 change: 1 addition & 0 deletions astroquery/alma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ def get_enhanced_table(result):
print(
"Could not import astropy-regions, which is a requirement for get_enhanced_table function in alma."
"Please refer to http://astropy-regions.readthedocs.io/en/latest/installation.html for how to install it.")
raise

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I thought I did this. Wondering if that got lost in the rebase exercise which gave me a bit of a headache...


def _parse_stcs_string(input):
csys = 'icrs'
Expand Down
11 changes: 9 additions & 2 deletions astroquery/alma/tests/test_alma_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
from astroquery.exceptions import CorruptDataWarning
from astroquery.alma import Alma, get_enhanced_table

try:
import regions

HAS_REGIONS = True
except ImportError:
HAS_REGIONS = False

# ALMA tests involving staging take too long, leading to travis timeouts
# TODO: make this a configuration item
SKIP_SLOW = True
Expand Down Expand Up @@ -62,11 +69,10 @@ def test_public(self, alma):
for row in results:
assert row['data_rights'] == 'Proprietary'

@pytest.mark.skipif(not HAS_REGIONS, reason="regions is required")
@pytest.mark.filterwarnings(
"ignore::astropy.utils.exceptions.AstropyUserWarning")
def test_s_region(self, alma):
pytest.importorskip('regions')
import regions # to silence checkstyle
alma.help_tap()
result = alma.query_tap("select top 3 s_region from ivoa.obscore")
enhanced_result = get_enhanced_table(result)
Expand All @@ -75,6 +81,7 @@ def test_s_region(self, alma):
regions.PolygonSkyRegion,
regions.CompoundSkyRegion))

@pytest.mark.skipif(not HAS_REGIONS, reason="regions is required")
@pytest.mark.filterwarnings(
"ignore::astropy.utils.exceptions.AstropyUserWarning")
def test_SgrAstar(self, tmp_path, alma):
Expand Down
Loading