Skip to content

Commit f15e7e0

Browse files
committed
case-insensitive query criteria
1 parent 471053f commit f15e7e0

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ mast
188188
- Present users with an error rather than a warning when nonexistent query criteria are used in ``mast.Observations.query_criteria``
189189
and ``mast.Catalogs.query_criteria``. [#3084]
190190

191+
- Support for case-insensitive criteria keyword arguments in ``mast.Observations.query_criteria`` and
192+
``mast.Catalogs.query_criteria``. [#3085]
193+
191194

192195
0.4.7 (2024-03-08)
193196
==================

astroquery/mast/discovery_portal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@ def build_filter_set(self, column_config_name, service_name=None, **filters):
404404
if np.isscalar(value,):
405405
value = [value]
406406

407-
# Get the column type and separator
408-
col_info = caom_col_config.get(colname)
407+
# Get the column type and separator with case-insensitive lookup
408+
col_info = next((v for k, v in caom_col_config.items() if k.lower() == colname.lower()), None)
409409
if not col_info:
410410
closest_match = difflib.get_close_matches(colname, caom_col_config.keys(), n=1)
411411
error_msg = f"Filter '{colname}' does not exist. Did you mean '{closest_match[0]}'?" if closest_match \

astroquery/mast/tests/test_mast_remote.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ def test_observations_query_criteria(self):
274274
intentType="calibration")
275275
assert (result["intentType"] == "calibration").all()
276276

277+
# with case-insensitive keyword arguments
278+
result = Observations.query_criteria(Instrument_Name="*WFPC2*",
279+
proposal_ID=8169,
280+
T_min=[51361, 51362])
281+
assert isinstance(result, Table)
282+
assert len(result) == 13
283+
277284
def test_observations_query_criteria_invalid_keyword(self):
278285
# attempt to make a criteria query with invalid keyword
279286
with pytest.raises(InvalidQueryError) as err_no_alt:
@@ -892,6 +899,18 @@ def check_result(result, exp_vals):
892899
assert isinstance(result, Table)
893900
assert result['distance'][0] <= result['distance'][1]
894901

902+
# with case-insensitive keyword arguments
903+
result = Catalogs.query_criteria(catalog="Tic",
904+
bMAG=[30, 50],
905+
objtype="STAR")
906+
check_result(result, {'ID': '81609218'})
907+
908+
result = Catalogs.query_criteria(catalog="DiskDetective",
909+
STATE=["inactive", "disabled"],
910+
oVaL=[8, 10],
911+
Multi=[3, 7])
912+
check_result(result, {'designation': 'J003920.04-300132.4'})
913+
895914
def test_catalogs_query_criteria_invalid_keyword(self):
896915
# attempt to make a criteria query with invalid keyword
897916
with pytest.raises(InvalidQueryError) as err_no_alt:

0 commit comments

Comments
 (0)