Skip to content

Commit

Permalink
Merge pull request #3039 from bsipocz/BUG_handling_optional_regions
Browse files Browse the repository at this point in the history
BUG: better handling the optional dependency required for functionality
  • Loading branch information
bsipocz authored Jun 14, 2024
2 parents 2f2a643 + a682a6a commit d7aba96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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

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

0 comments on commit d7aba96

Please sign in to comment.