Skip to content

Commit 54edbcb

Browse files
committed
Add docstrings to list_instruments and list_surveys
1 parent 19a9395 commit 54edbcb

File tree

1 file changed

+85
-27
lines changed

1 file changed

+85
-27
lines changed

astroquery/eso/core.py

Lines changed: 85 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ class EsoClass(QueryWithLogin):
107107

108108
def __init__(self):
109109
super().__init__()
110-
self._instruments: Optional[List[str]] = None
111-
self._surveys: Optional[List[str]] = None
112110
self._auth_info: Optional[AuthInfo] = None
113111
self._hash = None
114112
self._maxrec = None
@@ -287,45 +285,46 @@ def query_tap_service(self,
287285
return table_to_return
288286

289287
@unlimited_max_rec
290-
def list_instruments(self) -> List[str]:
291-
""" List all the available instrument-specific queries offered by the ESO archive.
288+
@deprecated_renamed_argument('cache', None, since='0.4.11')
289+
def list_instruments(self, cache=True) -> List[str]:
290+
"""
291+
List all the available instrument-specific queries offered by the ESO archive.
292292
293293
Returns
294294
-------
295295
instrument_list : list of strings
296+
cache : bool
297+
Deprecated - unused.
296298
"""
297-
if self._instruments is None:
298-
self._instruments = []
299-
query_str = ("select table_name from TAP_SCHEMA.tables "
300-
"where schema_name='ist' order by table_name")
301-
res = self.query_tap_service(query_str)["table_name"].data
302-
self._instruments = list(map(lambda x: x.split(".")[1], res))
303-
if len(self._instruments) < 1:
304-
self._instruments = None
305-
return self._instruments
299+
_ = cache # We're aware about disregarding the argument
300+
query_str = ("select table_name from TAP_SCHEMA.tables "
301+
"where schema_name='ist' order by table_name")
302+
res = self.query_tap_service(query_str)["table_name"].data
303+
l_res = list(map(lambda x: x.split(".")[1], res))
304+
305+
return l_res
306306

307307
@unlimited_max_rec
308-
def list_surveys(self) -> List[str]:
309-
""" List all the available surveys (phase 3) in the ESO archive.
308+
@deprecated_renamed_argument('cache', None, since='0.4.11')
309+
def list_surveys(self, *, cache=True) -> List[str]:
310+
"""
311+
List all the available surveys (phase 3) in the ESO archive.
310312
311313
Returns
312314
-------
313315
collection_list : list of strings
314316
cache : bool
315-
Defaults to True. If set overrides global caching behavior.
316-
See :ref:`caching documentation <astroquery_cache>`.
317+
Deprecated - unused.
317318
"""
318-
if self._surveys is None:
319-
self._surveys = []
320-
t = EsoNames.phase3_table
321-
c = EsoNames.phase3_surveys_column
322-
query_str = f"select distinct {c} from {t}"
323-
res = self.query_tap_service(query_str)[c].data
324-
self._surveys = list(res)
325-
return self._surveys
319+
_ = cache # We're aware about disregarding the argument
320+
t = EsoNames.phase3_table
321+
c = EsoNames.phase3_surveys_column
322+
query_str = f"select distinct {c} from {t}"
323+
res = list(self.query_tap_service(query_str)[c].data)
324+
return res
326325

327326
@unlimited_max_rec
328-
def print_table_help(self, table_name: str) -> None:
327+
def _print_table_help(self, table_name: str) -> None:
329328
"""
330329
Prints the columns contained in a given table
331330
"""
@@ -372,7 +371,7 @@ def _query_on_allowed_values(
372371
filters = {**dict(kwargs)}
373372

374373
if print_help:
375-
self.print_table_help(table_name)
374+
self._print_table_help(table_name)
376375
return
377376

378377
if (('box' in filters)
@@ -427,6 +426,65 @@ def query_surveys(
427426
column_filters: Optional[dict] = None,
428427
open_form: bool = False, cache: bool = False,
429428
**kwargs) -> Union[astropy.table.Table, int, str]:
429+
"""
430+
Query survey Phase 3 data contained in the ESO archive.
431+
432+
Parameters
433+
----------
434+
survey : string or list
435+
Name of the survey(s) to query. Should be one or more of the
436+
names returned by `~astroquery.eso.EsoClass.list_surveys`. If
437+
specified as a string, should be a comma-separated list of
438+
survey names.
439+
ra : float
440+
Cone Search Center - Right Ascention in deg.
441+
dec : float
442+
Cone Search Center - Declination in deg.
443+
radius : float
444+
Cone Search Radius in deg.
445+
columns: string or list of strings
446+
Name of the columns the query should return.
447+
If specified as a string, should be a comma-separated list
448+
of column names.
449+
top : int
450+
When set top = N, returns only the top N records.
451+
count_only : bool
452+
Defaults to `False`.
453+
When set to `True`, returns only an `int`: the count
454+
of the records the query would return when set to `False`.
455+
query_str_only : bool
456+
Defaults to `False`.
457+
When set to `True`, returns only a `str`: the query
458+
string that would be issued to the TAP service.
459+
help : bool
460+
If `True`, prints all the parameters accepted in
461+
``column_filters`` and ``columns``.
462+
authenticated : bool
463+
If `True`, run the query as an authenticated user.
464+
Authentication must be done beforehand via
465+
`~astroquery.eso.EsoClass.login`
466+
Note that authenticated queries take longer.
467+
column_filters : dict
468+
Constraints applied to the query.
469+
open_form : bool
470+
Deprecated - unused.
471+
cache : bool
472+
Deprecated - unused.
473+
474+
Returns
475+
-------
476+
table : `~astropy.table.Table`, `str`, `int` or `None`
477+
A table representing the data available in the archive for the
478+
specified columns and constraints.
479+
`None` is returned when the query has no results.
480+
481+
When ``count_only`` is `True`, returns as an `int` record
482+
count for the specified filters.
483+
484+
When ``query_str_only`` is `True`, returns the query string
485+
that would be issued to the TAP service given the specified
486+
arguments.
487+
"""
430488
_ = open_form, cache # make explicit that we are aware these arguments are unused
431489
c = column_filters if column_filters else {}
432490
kwargs = {**kwargs, **c}

0 commit comments

Comments
 (0)