Skip to content

Commit 4f46cd4

Browse files
committed
ENH: making Irsa.query_region spatial keyword case insensitive
1 parent 8192801 commit 4f46cd4

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

astroquery/ipac/irsa/core.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,11 @@ def query_region(self, coordinates=None, *, catalog=None, spatial='Cone',
208208

209209
adql = f'SELECT {columns} FROM {catalog}'
210210

211-
if spatial == 'All-Sky':
211+
spatial = spatial.lower()
212+
213+
if spatial == 'all-sky' or spatial == 'allsky':
212214
where = ''
213-
elif spatial == 'Polygon':
215+
elif spatial == 'polygon':
214216
try:
215217
coordinates_list = [parse_coordinates(coord).icrs for coord in polygon]
216218
except TypeError:
@@ -229,12 +231,12 @@ def query_region(self, coordinates=None, *, catalog=None, spatial='Cone',
229231
coords_icrs = parse_coordinates(coordinates).icrs
230232
ra, dec = coords_icrs.ra.deg, coords_icrs.dec.deg
231233

232-
if spatial == 'Cone':
234+
if spatial == 'cone':
233235
if isinstance(radius, str):
234236
radius = Angle(radius)
235237
where = (" WHERE CONTAINS(POINT('ICRS',ra,dec),"
236238
f"CIRCLE('ICRS',{ra},{dec},{radius.to(u.deg).value}))=1")
237-
elif spatial == 'Box':
239+
elif spatial == 'box':
238240
if isinstance(width, str):
239241
width = Angle(width)
240242
where = (" WHERE CONTAINS(POINT('ICRS',ra,dec),"

astroquery/ipac/irsa/tests/test_irsa.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_query_region_box(coordinates, width):
4848
def test_query_region_polygon(polygon):
4949
query1 = Irsa.query_region(catalog="fp_psc", spatial="Polygon", polygon=polygon,
5050
get_query_payload=True)
51-
query2 = Irsa.query_region("m31", catalog="fp_psc", spatial="Polygon", polygon=polygon,
51+
query2 = Irsa.query_region("m31", catalog="fp_psc", spatial="polygon", polygon=polygon,
5252
get_query_payload=True)
5353

5454
assert query1 == query2
@@ -58,12 +58,12 @@ def test_query_region_polygon(polygon):
5858

5959
def test_query_allsky():
6060
query1 = Irsa.query_region(catalog="fp_psc", spatial="All-Sky", get_query_payload=True)
61-
query2 = Irsa.query_region("m31", catalog="fp_psc", spatial="All-Sky", get_query_payload=True)
61+
query2 = Irsa.query_region("m31", catalog="fp_psc", spatial="allsky", get_query_payload=True)
6262

6363
assert query1 == query2 == "SELECT * FROM fp_psc"
6464

6565

66-
@pytest.mark.parametrize('spatial', ['cone', 'box', 'polygon', 'all-Sky', 'All-sky', 'invalid'])
66+
@pytest.mark.parametrize('spatial', ['random_nonsense', 'invalid'])
6767
def test_spatial_invalid(spatial):
6868
with pytest.raises(ValueError):
6969
Irsa.query_region(OBJ_LIST[0], catalog='invalid_spatial', spatial=spatial)

0 commit comments

Comments
 (0)