Skip to content

Commit 0891d27

Browse files
committed
put back help, open_form, filter_columns arguments
1 parent 4fe7d8d commit 0891d27

File tree

3 files changed

+63
-38
lines changed

3 files changed

+63
-38
lines changed

astroquery/eso/core.py

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ def _query_on_allowed_values(
412412

413413
return retval
414414

415+
@deprecated_renamed_argument(('open_form', 'cache'), (None, None),
416+
since=['0.4.11', '0.4.11'])
415417
def query_surveys(
416418
self,
417419
surveys: Union[List[str], str] = None, *,
@@ -420,9 +422,14 @@ def query_surveys(
420422
top: int = None,
421423
count_only: bool = False,
422424
query_str_only: bool = False,
423-
print_help: bool = False,
425+
help: bool = False,
424426
authenticated: bool = False,
427+
column_filters: Optional[dict] = None,
428+
open_form: bool = False, cache: bool = False,
425429
**kwargs) -> Union[astropy.table.Table, int, str]:
430+
_ = open_form, cache # make explicit that we are aware these arguments are unused
431+
c = column_filters if column_filters else {}
432+
kwargs = {**kwargs, **c}
426433
return self._query_on_allowed_values(table_name=EsoNames.phase3_table,
427434
column_name=EsoNames.phase3_surveys_column,
428435
allowed_values=surveys,
@@ -431,10 +438,12 @@ def query_surveys(
431438
top=top,
432439
count_only=count_only,
433440
query_str_only=query_str_only,
434-
print_help=print_help,
441+
print_help=help,
435442
authenticated=authenticated,
436443
**kwargs)
437444

445+
@deprecated_renamed_argument(('open_form', 'cache'), (None, None),
446+
since=['0.4.11', '0.4.11'])
438447
def query_main(
439448
self,
440449
instruments: Union[List[str], str] = None, *,
@@ -443,9 +452,14 @@ def query_main(
443452
top: int = None,
444453
count_only: bool = False,
445454
query_str_only: bool = False,
446-
print_help: bool = False,
455+
help: bool = False,
447456
authenticated: bool = False,
457+
column_filters: Optional[dict] = None,
458+
open_form: bool = False, cache: bool = False,
448459
**kwargs) -> Union[astropy.table.Table, int, str]:
460+
_ = open_form, cache # make explicit that we are aware these arguments are unused
461+
c = column_filters if column_filters else {}
462+
kwargs = {**kwargs, **c}
449463
return self._query_on_allowed_values(table_name=EsoNames.raw_table,
450464
column_name=EsoNames.raw_instruments_column,
451465
allowed_values=instruments,
@@ -454,11 +468,12 @@ def query_main(
454468
top=top,
455469
count_only=count_only,
456470
query_str_only=query_str_only,
457-
print_help=print_help,
471+
print_help=help,
458472
authenticated=authenticated,
459473
**kwargs)
460474

461-
# ex query_instrument
475+
@deprecated_renamed_argument(('open_form', 'cache'), (None, None),
476+
since=['0.4.11', '0.4.11'])
462477
def query_instrument(
463478
self,
464479
instrument: str, *,
@@ -467,9 +482,14 @@ def query_instrument(
467482
top: int = None,
468483
count_only: bool = False,
469484
query_str_only: bool = False,
470-
print_help: bool = False,
485+
help: bool = False,
471486
authenticated: bool = False,
487+
column_filters: Optional[dict] = None,
488+
open_form: bool = False, cache: bool = False,
472489
**kwargs) -> Union[astropy.table.Table, int, str]:
490+
_ = open_form, cache # make explicit that we are aware these arguments are unused
491+
c = column_filters if column_filters else {}
492+
kwargs = {**kwargs, **c}
473493
return self._query_on_allowed_values(table_name=EsoNames.ist_table(instrument),
474494
column_name=None,
475495
allowed_values=None,
@@ -478,7 +498,7 @@ def query_instrument(
478498
top=top,
479499
count_only=count_only,
480500
query_str_only=query_str_only,
481-
print_help=print_help,
501+
print_help=help,
482502
authenticated=authenticated,
483503
**kwargs)
484504

@@ -786,10 +806,12 @@ def retrieve_data(self, datasets, *, continuation=False, destination=None,
786806
log.info("Done!")
787807
return files[0] if files and len(files) == 1 and return_string else files
788808

789-
@deprecated_renamed_argument(('open_form', 'help'), (None, 'print_help'),
790-
since=['0.4.8', '0.4.8'])
791-
def query_apex_quicklooks(self, *, project_id=None, print_help=False,
792-
open_form=False, **kwargs):
809+
@deprecated_renamed_argument(('open_form', 'cache'), (None, None),
810+
since=['0.4.11', '0.4.11'])
811+
def query_apex_quicklooks(self, *, project_id=None, help: bool = False,
812+
column_filters: Optional[dict] = None,
813+
open_form: bool = False, cache: bool = False,
814+
**kwargs):
793815
"""
794816
APEX data are distributed with quicklook products identified with a
795817
different name than other ESO products. This query tool searches by
@@ -801,7 +823,8 @@ def query_apex_quicklooks(self, *, project_id=None, print_help=False,
801823
>>> files = ...
802824
"""
803825
# TODO All this function
804-
_ = project_id, print_help, open_form, kwargs
826+
# make explicit that we are aware these arguments are unused
827+
_ = project_id, help, column_filters, open_form, cache, kwargs
805828
raise NotImplementedError
806829

807830

astroquery/eso/tests/test_eso.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
from ...exceptions import NoResultsWarning, MaxResultsWarning
2323

2424
DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
25+
EXPECTED_MAXREC = 1000
26+
MONKEYPATCH_TABLE_LENGTH = 50
2527

2628

2729
def data_path(filename):
@@ -123,7 +125,7 @@ def test_sinfoni_sgr_a_star(monkeypatch):
123125
monkeypatch.setattr(eso, 'query_tap_service', monkey_tap)
124126
result = eso.query_instrument('sinfoni', target='SGRA')
125127
# test all results are there and the expected target is present
126-
assert len(result) == 50
128+
assert len(result) == MONKEYPATCH_TABLE_LENGTH
127129
assert 'SGRA' in result['target']
128130

129131

@@ -147,7 +149,7 @@ def test_vvv(monkeypatch):
147149
radius=0.1775,
148150
)
149151
# test all results are there and the expected target is present
150-
assert len(result) == 50
152+
assert len(result) == MONKEYPATCH_TABLE_LENGTH
151153
assert 'target_name' in result.colnames
152154
assert 'b333' in result['target_name']
153155

@@ -216,7 +218,7 @@ def test_calselector(monkeypatch, tmp_path):
216218
monkeypatch.setattr(eso._session, 'post', calselector_request)
217219
result = eso.get_associated_files([dataset], savexml=True)
218220
assert isinstance(result, list)
219-
assert len(result) == 50
221+
assert len(result) == MONKEYPATCH_TABLE_LENGTH
220222
assert dataset not in result
221223

222224

@@ -276,9 +278,9 @@ def test_adql_sanitize_val():
276278
def test_maxrec():
277279
eso_instance = Eso()
278280

279-
# 50 is the default value in the conf
281+
# EXPECTED_MAXREC is the default value in the conf
280282
maxrec = eso_instance.maxrec
281-
assert maxrec == 50
283+
assert maxrec == EXPECTED_MAXREC
282284

283285
# we change it to 5
284286
eso_instance.maxrec = 5
@@ -321,8 +323,8 @@ def test_issue_table_length_warnings():
321323
with pytest.warns(NoResultsWarning):
322324
eso_instance._maybe_warn_about_table_length(t)
323325

324-
# should warn, since 50 = eso_instance.maxrec
325-
t = Table({"col_name": [i for i in range(50)]})
326+
# should warn, since EXPECTED_MAXREC = eso_instance.maxrec
327+
t = Table({"col_name": [i for i in range(EXPECTED_MAXREC)]})
326328
with pytest.warns(MaxResultsWarning):
327329
eso_instance._maybe_warn_about_table_length(t)
328330

astroquery/eso/tests/test_eso_remote.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -169,27 +169,29 @@ def test_empty_return(self):
169169
assert len(result_s) == 0
170170

171171
@pytest.mark.filterwarnings("ignore::pyvo.dal.exceptions.DALOverflowWarning")
172-
def test_sgrastar_remote_vs_local(self, tmp_path):
172+
def test_sgrastar_column_filters(self, tmp_path):
173173
eso = Eso()
174-
# TODO originally it was 'gravity', but it is not yet ready in the TAP ISTs
175-
instrument = 'uves'
176174

177-
# Remote version
178-
with pytest.warns(MaxResultsWarning):
179-
result1 = eso.query_instrument(instrument, ra=266.41681662,
180-
dec=-29.00782497, radius=1.0)
181-
# Local version
182-
eso.cache_location = tmp_path
183-
with pytest.warns(MaxResultsWarning):
184-
result2 = eso.query_instrument(instrument, ra=266.41681662,
185-
dec=-29.00782497, radius=1.0)
175+
result1 = eso.query_surveys(["sphere", "vegas"],
176+
columns="obs_collection, calib_level, multi_ob, filter, s_pixel_scale, instrument_name",
177+
calib_level=3,
178+
multi_ob='M'
179+
)
180+
181+
result2 = eso.query_surveys("sphere, vegas",
182+
columns="obs_collection, calib_level, multi_ob, filter, s_pixel_scale, instrument_name",
183+
column_filters={
184+
'calib_level': 3,
185+
'multi_ob': 'M'
186+
}
187+
)
188+
186189
assert all(result1.values_equal(result2))
187190

188191
def test_list_instruments(self):
189192
# If this test fails, we may simply need to update it
190193
inst = set(Eso.list_instruments())
191-
assert set(inst) == set(instrument_list), \
192-
f"Expected result {instrument_list}; Obtained: {inst}"
194+
assert set(inst) == set(instrument_list), f"Expected result {instrument_list}; Obtained: {inst}"
193195

194196
def test_retrieve_data(self):
195197
eso = Eso()
@@ -217,7 +219,7 @@ def test_retrieve_data_list(self):
217219
@pytest.mark.parametrize('instrument', instrument_list)
218220
def test_help(self, instrument):
219221
eso = Eso()
220-
eso.query_instrument(instrument, print_help=True)
222+
eso.query_instrument(instrument, help=True)
221223

222224
def test_apex_retrieval(self):
223225
raise NotImplementedError
@@ -261,10 +263,8 @@ def test_each_collection_sgrastar(self, tmp_path):
261263
with pytest.warns(MaxResultsWarning):
262264
generic_result = eso.query_surveys(surveys=collection)
263265

264-
assert generic_result is not None, \
265-
f"query_collection({collection}) returned None"
266-
assert len(generic_result) > 0, \
267-
f"query_collection({collection}) returned no records"
266+
assert generic_result is not None, f"query_collection({collection}) returned None"
267+
assert len(generic_result) > 0, f"query_collection({collection}) returned no records"
268268

269269
@pytest.mark.filterwarnings("ignore::pyvo.dal.exceptions.DALOverflowWarning")
270270
def test_mixed_case_instrument(self, tmp_path):

0 commit comments

Comments
 (0)