Skip to content

Commit

Permalink
docs: edit version of deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
ManonMarchand committed Jun 3, 2024
1 parent a29dc9a commit 4c5cd0e
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 19 deletions.
81 changes: 62 additions & 19 deletions astroquery/simbad/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import astropy.units as u
from astropy.utils import isiterable
from astropy.utils.data import get_pkg_data_filename
from astropy.utils.decorators import deprecated_renamed_argument

from astroquery.query import BaseVOQuery
from astroquery.utils import commons, async_to_sync
Expand Down Expand Up @@ -401,6 +402,8 @@ def add_output_columns(self, *args):
# Query methods
# -------------

@deprecated_renamed_argument(["verbose", "get_query_payload"], new_name=[None, "get_adql"],
since=['0.4.8', '0.4.8'], relax=True)
def query_object(self, object_name, *, wildcard=False,
criteria=None, get_adql=False,
verbose=False, get_query_payload=False):
Expand All @@ -421,8 +424,8 @@ def query_object(self, object_name, *, wildcard=False,
syntax in a single string. See example.
get_adql : bool, defaults to False
Returns the ADQL string instead of querying SIMBAD.
verbose : deprecated since 0.4.7
get_query_payload : deprecated since 0.4.7
verbose : deprecated since 0.4.8
get_query_payload : deprecated since 0.4.8
Returns
-------
Expand Down Expand Up @@ -478,8 +481,13 @@ def query_object(self, object_name, *, wildcard=False,
if criteria:
instance_criteria.append(f"({criteria})")

if get_query_payload:
get_adql = True

return self._construct_query(top, columns, joins, instance_criteria, get_adql)

@deprecated_renamed_argument(["verbose", "get_query_payload"], new_name=[None, "get_adql"],
since=['0.4.8', '0.4.8'], relax=True)
def query_objects(self, object_names, *, wildcard=False, criteria=None,
get_adql=False, verbose=False, get_query_payload=False):
"""Query SIMBAD for the specified list of objects.
Expand All @@ -501,8 +509,8 @@ def query_objects(self, object_names, *, wildcard=False, criteria=None,
syntax in a single string. See example.
get_adql : bool, defaults to False
Returns the ADQL string instead of querying SIMBAD.
verbose : deprecated since 0.4.7
get_query_payload : deprecated since 0.4.7
verbose : deprecated since 0.4.8
get_query_payload : deprecated since 0.4.8
Returns
-------
Expand Down Expand Up @@ -547,8 +555,14 @@ def query_objects(self, object_names, *, wildcard=False, criteria=None,
if criteria:
instance_criteria.append(f"({criteria})")

if get_query_payload:
get_adql = True

return self._construct_query(top, columns, joins, instance_criteria, get_adql, script_infos=upload)

@deprecated_renamed_argument(["get_query_payload", "equinox", "epoch", "cache"],
new_name=["get_adql", None, None, None],
since=['0.4.8', '0.4.8', '0.4.8', '0.4.8'], relax=True)
def query_region(self, coordinates, radius=2*u.arcmin, *,
criteria=None, get_adql=False,
equinox=None, epoch=None, cache=None,
Expand All @@ -566,12 +580,12 @@ def query_region(self, coordinates, radius=2*u.arcmin, *,
syntax in a single string.
get_adql : bool, defaults to False
Returns the ADQL string instead of querying SIMBAD.
equinox : deprecated since 0.4.7
equinox : deprecated since 0.4.8
Use `~astropy.coordinates` objects instead
epoch : deprecated since 0.4.7
epoch : deprecated since 0.4.8
Use `~astropy.coordinates` objects instead
get_query_payload : deprecated since 0.4.7
cache : deprecated since 0.4.7
get_query_payload : deprecated since 0.4.8
cache : deprecated since 0.4.8
Returns
-------
Expand Down Expand Up @@ -652,8 +666,14 @@ def query_region(self, coordinates, radius=2*u.arcmin, *,
if criteria:
instance_criteria.append(f"({criteria})")

if get_query_payload:
get_adql = True

return self._construct_query(top, columns, joins, instance_criteria, get_adql)

@deprecated_renamed_argument(["verbose", "cache", "get_query_payload"],
new_name=[None, None, "get_adql"],
since=['0.4.8', '0.4.8', '0.4.8'], relax=True)
def query_catalog(self, catalog, *, criteria=None, get_adql=False,
verbose=False, cache=True, get_query_payload=False):
"""Query a whole catalog.
Expand All @@ -667,9 +687,9 @@ def query_catalog(self, catalog, *, criteria=None, get_adql=False,
syntax in a single string. See example.
get_adql : bool, defaults to False
Returns the ADQL string instead of querying SIMBAD.
verbose : deprecated since 0.4.7
get_query_payload : deprecated since 0.4.7
cache : deprecated since 0.4.7
verbose : deprecated since 0.4.8
get_query_payload : deprecated since 0.4.8
cache : deprecated since 0.4.8
Returns
-------
Expand Down Expand Up @@ -709,8 +729,13 @@ def query_catalog(self, catalog, *, criteria=None, get_adql=False,
if criteria:
instance_criteria.append(f"({criteria})")

if get_query_payload:
get_adql = True

return self._construct_query(top, columns, joins, instance_criteria, get_adql)

@deprecated_renamed_argument(["verbose", "get_query_payload"], new_name=[None, "get_adql"],
since=['0.4.8', '0.4.8'], relax=True)
def query_bibobj(self, bibcode, *, criteria=None,
get_adql=False,
verbose=False, get_query_payload=False):
Expand All @@ -723,8 +748,8 @@ def query_bibobj(self, bibcode, *, criteria=None,
get_query_payload : bool, optional
When set to `True` the method returns the HTTP request parameters.
Defaults to `False`.
verbose : deprecated since 0.4.7
get_query_payload : deprecated since 0.4.7
verbose : deprecated since 0.4.8
get_query_payload : deprecated since 0.4.8
Returns
-------
Expand All @@ -745,8 +770,14 @@ def query_bibobj(self, bibcode, *, criteria=None,
if criteria:
instance_criteria.append(f"({criteria})")

if get_query_payload:
get_adql = True

return self._construct_query(top, columns, joins, instance_criteria, get_adql)

@deprecated_renamed_argument(["verbose", "get_query_payload", "cache"],
new_name=[None, "get_adql", None],
since=['0.4.8', '0.4.8', '0.4.8'], relax=True)
def query_bibcode(self, bibcode, *, wildcard=False,
abstract=False, get_adql=False, criteria=None,
verbose=None,
Expand All @@ -768,9 +799,11 @@ def query_bibcode(self, bibcode, *, wildcard=False,
criteria : str
Criteria to be applied to the query. These should be written in the ADQL
syntax in a single string. See example.
verbose : deprecated since 0.4.7
get_query_payload : deprecated since 0.4.7
cache : deprecated since 0.4.7
verbose : deprecated since 0.4.8
get_query_payload : deprecated since 0.4.8
cache : The cache is now bound to the python session. It can be emptied with
`~astroquery.simbad.SimbadClass.empty_cache()` but cannot be deactivated
from here. Deprecated since 0.4.8
Returns
-------
Expand Down Expand Up @@ -813,10 +846,16 @@ def query_bibcode(self, bibcode, *, wildcard=False,

query += " ORDER BY bibcode"

if get_query_payload:
get_adql = True

if get_adql:
return query
return self.query_tap(query)

@deprecated_renamed_argument(["verbose", "get_query_payload", "cache"],
new_name=[None, "get_adql", None],
since=['0.4.8', '0.4.8', '0.4.8'], relax=True)
def query_objectids(self, object_name, *, verbose=None, cache=None,
get_query_payload=None, criteria=None,
get_adql=False):
Expand All @@ -834,9 +873,9 @@ def query_objectids(self, object_name, *, verbose=None, cache=None,
the column ``ident.id``.
get_adql : bool, optional
Returns the ADQL string instead of querying SIMBAD, by default False.
verbose : deprecated since 0.4.7
get_query_payload : deprecated since 0.4.7
cache : deprecated since 0.4.7
verbose : deprecated since 0.4.8
get_query_payload : deprecated since 0.4.8
cache : deprecated since 0.4.8
Returns
-------
Expand Down Expand Up @@ -876,6 +915,10 @@ def query_objectids(self, object_name, *, verbose=None, cache=None,
f"WHERE id_typed.id = '{_adql_parameter(object_name)}'")
if criteria is not None:
query += f" AND {criteria}"

if get_query_payload:
get_adql = True

if get_adql:
return query
return self.query_tap(query)
Expand Down
22 changes: 22 additions & 0 deletions astroquery/simbad/tests/test_simbad.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from astropy.io.votable import parse_single_table
from astropy.table import Table
import astropy.units as u
from astropy.utils.exceptions import AstropyDeprecationWarning
from pyvo.dal.tap import TAPService

import pytest
Expand Down Expand Up @@ -483,3 +484,24 @@ def test_construct_query():
[column],
[],
["ra < 6", "ra > 5"], get_adql=True) == expected


@pytest.mark.usefixtures("_mock_simbad_class")
@pytest.mark.parametrize(
("query_method", "args", "deprecated_kwargs"),
[
(simbad.Simbad.query_objectids, ["M1"], {"verbose", "get_query_payload", "cache"}),
(simbad.Simbad.query_bibcode, ["1992AJ....103..983B"], {"verbose", "get_query_payload", "cache"}),
(simbad.Simbad.query_bibobj, ["1992AJ....103..983B"], {"verbose", "get_query_payload"}),
(simbad.Simbad.query_catalog, ["M"], {"verbose", "get_query_payload", "cache"}),
(simbad.Simbad.query_region, ["M1", "2d"], {"get_query_payload", "equinox", "epoch", "cache"}),
(simbad.Simbad.query_objects, [["M1", "M2"]], {"verbose", "get_query_payload"}),
(simbad.Simbad.query_object, ["M1"], {"verbose", "get_query_payload"}),
]
)
def test_deprecated_arguments(query_method, args, deprecated_kwargs):
for argument in deprecated_kwargs:
with pytest.warns(AstropyDeprecationWarning,
match=f'"{argument}" was deprecated in version 0.4.8 and will be '
'removed in a future version.*'):
query_method(*args, get_adql=True, **{argument: True})

0 comments on commit 4c5cd0e

Please sign in to comment.