Skip to content

Commit 25646ef

Browse files
nkphysicsbsipocz
authored andcommitted
Refactor: Made eso kwargs keyword only
1 parent da24a24 commit 25646ef

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

astroquery/eso/core.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self):
4848
self._survey_list = None
4949
self.username = None
5050

51-
def _activate_form(self, response, form_index=0, form_id=None, inputs={},
51+
def _activate_form(self, response, *, form_index=0, form_id=None, inputs={},
5252
cache=True, method=None):
5353
"""
5454
Parameters
@@ -191,7 +191,7 @@ def _activate_form(self, response, form_index=0, form_id=None, inputs={},
191191

192192
return response
193193

194-
def _login(self, username=None, store_password=False,
194+
def _login(self, *, username=None, store_password=False,
195195
reenter_password=False):
196196
"""
197197
Login to the ESO User Portal.
@@ -257,7 +257,7 @@ def _login(self, username=None, store_password=False,
257257
keyring.set_password("astroquery:www.eso.org", username, password)
258258
return authenticated
259259

260-
def list_instruments(self, cache=True):
260+
def list_instruments(self, *, cache=True):
261261
""" List all the available instrument-specific queries offered by the ESO archive.
262262
263263
Returns
@@ -280,7 +280,7 @@ def list_instruments(self, cache=True):
280280
self._instrument_list.append(instrument)
281281
return self._instrument_list
282282

283-
def list_surveys(self, cache=True):
283+
def list_surveys(self, *, cache=True):
284284
""" List all the available surveys (phase 3) in the ESO archive.
285285
286286
Returns
@@ -311,7 +311,7 @@ def list_surveys(self, cache=True):
311311
self._survey_list.append(survey)
312312
return self._survey_list
313313

314-
def query_surveys(self, surveys='', cache=True,
314+
def query_surveys(self, *, surveys='', cache=True,
315315
help=False, open_form=False, **kwargs):
316316
"""
317317
Query survey Phase 3 data contained in the ESO archive.
@@ -369,7 +369,7 @@ def query_surveys(self, surveys='', cache=True,
369369
else:
370370
warnings.warn("Query returned no results", NoResultsWarning)
371371

372-
def query_main(self, column_filters={}, columns=[],
372+
def query_main(self, *, column_filters={}, columns=[],
373373
open_form=False, help=False, cache=True, **kwargs):
374374
"""
375375
Query raw data contained in the ESO archive.
@@ -403,7 +403,7 @@ def query_main(self, column_filters={}, columns=[],
403403
return self._query(url, column_filters=column_filters, columns=columns,
404404
open_form=open_form, help=help, cache=cache, **kwargs)
405405

406-
def query_instrument(self, instrument, column_filters={}, columns=[],
406+
def query_instrument(self, instrument, *, column_filters={}, columns=[],
407407
open_form=False, help=False, cache=True, **kwargs):
408408
"""
409409
Query instrument-specific raw data contained in the ESO archive.
@@ -441,7 +441,7 @@ def query_instrument(self, instrument, column_filters={}, columns=[],
441441
return self._query(url, column_filters=column_filters, columns=columns,
442442
open_form=open_form, help=help, cache=cache, **kwargs)
443443

444-
def _query(self, url, column_filters={}, columns=[],
444+
def _query(self, url, *, column_filters={}, columns=[],
445445
open_form=False, help=False, cache=True, **kwargs):
446446

447447
table = None
@@ -486,7 +486,7 @@ def _query(self, url, column_filters={}, columns=[],
486486
else:
487487
warnings.warn("Query returned no results", NoResultsWarning)
488488

489-
def get_headers(self, product_ids, cache=True):
489+
def get_headers(self, product_ids, *, cache=True):
490490
"""
491491
Get the headers associated to a list of data product IDs
492492
@@ -557,7 +557,7 @@ def get_headers(self, product_ids, cache=True):
557557
# Return as Table
558558
return Table(result)
559559

560-
def _check_existing_files(self, datasets, continuation=False,
560+
def _check_existing_files(self, datasets, *, continuation=False,
561561
destination=None):
562562
"""Detect already downloaded datasets."""
563563

@@ -628,7 +628,7 @@ def _download_file(self, url, local_filepath, **kwargs):
628628

629629
return resp
630630

631-
def retrieve_data(self, datasets, continuation=False, destination=None,
631+
def retrieve_data(self, datasets, *, continuation=False, destination=None,
632632
with_calib='none', request_all_objects=False,
633633
unzip=True, request_id=None):
634634
"""
@@ -891,7 +891,7 @@ def verify_data_exists(self, dataset):
891891

892892
return 'No data returned' not in content
893893

894-
def query_apex_quicklooks(self, project_id=None, help=False,
894+
def query_apex_quicklooks(self, *, project_id=None, help=False,
895895
open_form=False, cache=True, **kwargs):
896896
"""
897897
APEX data are distributed with quicklook products identified with a
@@ -900,7 +900,7 @@ def query_apex_quicklooks(self, project_id=None, help=False,
900900
901901
Examples
902902
--------
903-
>>> tbl = Eso.query_apex_quicklooks('093.C-0144')
903+
>>> tbl = Eso.query_apex_quicklooks(project_id='093.C-0144')
904904
>>> files = Eso.retrieve_data(tbl['Product ID'])
905905
"""
906906

@@ -944,7 +944,7 @@ def query_apex_quicklooks(self, project_id=None, help=False,
944944

945945
return table
946946

947-
def _print_query_help(self, url, cache=True):
947+
def _print_query_help(self, url, *, cache=True):
948948
"""
949949
Download a form and print it in a quasi-human-readable way
950950
"""
@@ -1006,7 +1006,7 @@ def _print_query_help(self, url, cache=True):
10061006
log.info("\n".join(result_string))
10071007
return result_string
10081008

1009-
def _print_surveys_help(self, url, cache=True):
1009+
def _print_surveys_help(self, url, *, cache=True):
10101010
"""
10111011
Download a form and print it in a quasi-human-readable way
10121012
"""

astroquery/eso/tests/test_eso.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_vvv(monkeypatch):
8585
monkeypatch.setattr(eso, '_request', eso_request)
8686
eso.cache_location = DATA_DIR
8787

88-
result_s = eso.query_surveys('VVV',
88+
result_s = eso.query_surveys(surveys='VVV',
8989
coord1=266.41681662, coord2=-29.00782497,
9090
box='01 00 00',
9191
)

astroquery/eso/tests/test_eso_remote.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_SgrAstar(self, tmp_path):
3737
assert len(surveys) > 0
3838
# result_s = eso.query_surveys('VVV', target='Sgr A*')
3939
# Equivalent, does not depend on SESAME:
40-
result_s = eso.query_surveys('VVV', coord1=266.41681662,
40+
result_s = eso.query_surveys(surveys='VVV', coord1=266.41681662,
4141
coord2=-29.00782497,
4242
box='01 00 00',
4343
cache=False)
@@ -57,7 +57,7 @@ def test_multisurvey(self, tmp_path):
5757
# first b333 was at 157
5858
# first pistol....?
5959

60-
result_s = eso.query_surveys(['VVV', 'XSHOOTER'],
60+
result_s = eso.query_surveys(surveys=['VVV', 'XSHOOTER'],
6161
coord1=266.41681662,
6262
coord2=-29.00782497,
6363
box='01 00 00',
@@ -88,7 +88,7 @@ def test_empty_return(self):
8888

8989
# Avoid SESAME
9090
with pytest.warns(NoResultsWarning):
91-
result_s = eso.query_surveys(surveys[0], coord1=202.469575,
91+
result_s = eso.query_surveys(surveys=surveys[0], coord1=202.469575,
9292
coord2=47.195258, cache=False)
9393

9494
assert result_s is None
@@ -158,7 +158,7 @@ def test_apex_retrieval(self):
158158
eso = Eso()
159159

160160
tbl = eso.query_apex_quicklooks(prog_id='095.F-9802')
161-
tblb = eso.query_apex_quicklooks('095.F-9802')
161+
tblb = eso.query_apex_quicklooks(project_id='095.F-9802')
162162

163163
assert len(tbl) == 5
164164
assert set(tbl['Release Date']) == {'2015-07-17', '2015-07-18',
@@ -190,20 +190,20 @@ def test_each_survey_and_SgrAstar(self, tmp_path):
190190
surveys = eso.list_surveys(cache=False)
191191
for survey in surveys:
192192
if survey in SGRA_SURVEYS:
193-
result_s = eso.query_surveys(survey, coord1=266.41681662,
193+
result_s = eso.query_surveys(surveys=survey, coord1=266.41681662,
194194
coord2=-29.00782497,
195195
box='01 00 00',
196196
cache=False)
197197
assert len(result_s) > 0
198198
else:
199199
with pytest.warns(NoResultsWarning):
200-
result_s = eso.query_surveys(survey, coord1=266.41681662,
200+
result_s = eso.query_surveys(surveys=survey, coord1=266.41681662,
201201
coord2=-29.00782497,
202202
box='01 00 00',
203203
cache=False)
204204
assert result_s is None
205205

206-
generic_result = eso.query_surveys(survey)
206+
generic_result = eso.query_surveys(surveys=survey)
207207
assert len(generic_result) > 0
208208

209209
def test_mixed_case_instrument(self, tmp_path):

docs/eso/eso.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ The archive can be queried as follows:
282282

283283
.. doctest-remote-data::
284284

285-
>>> table = eso.query_surveys('HARPS', cache=False, target="HD203608")
285+
>>> table = eso.query_surveys(surveys='HARPS', cache=False, target="HD203608")
286286

287287
The returned table has an ``ARCFILE`` column. It can be used to retrieve the datasets with
288288
:meth:`astroquery.eso.EsoClass.retrieve_data` (see next section).

0 commit comments

Comments
 (0)