Skip to content

Commit

Permalink
Deprecate get_raw_response.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkelley committed Jun 9, 2022
1 parent 55642bc commit 21844a7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 22 deletions.
20 changes: 19 additions & 1 deletion astroquery/jplhorizons/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from astropy.io import ascii
from astropy.time import Time
from astropy.utils.exceptions import AstropyDeprecationWarning
from astropy.utils.decorators import deprecated_renamed_argument

# 3. local imports - use relative imports
# commonly required local imports shown below as example
Expand Down Expand Up @@ -165,6 +166,8 @@ def __str__(self):

# ---------------------------------- query functions

@deprecated_renamed_argument("get_raw_response", None, since="0.4.7",
alternative="async methods")
def ephemerides_async(self, airmass_lessthan=99,
solar_elongation=(0, 180), max_hour_angle=0,
rate_cutoff=None,
Expand All @@ -179,6 +182,10 @@ def ephemerides_async(self, airmass_lessthan=99,
"""
Query JPL Horizons for ephemerides.
.. deprecated:: 0.4.7
The ``get_raw_response`` keyword argument is deprecated. The
`~HorizonsClass.ephemerides_async` method will return a raw response.
The ``location`` parameter in ``HorizonsClass`` refers in this case to
the location of the observer.
Expand Down Expand Up @@ -492,7 +499,6 @@ def ephemerides_async(self, airmass_lessthan=99,
response : `requests.Response`
The response of the HTTP request.
Examples
--------
Expand Down Expand Up @@ -632,6 +638,8 @@ def ephemerides_async(self, airmass_lessthan=99,

return response

@deprecated_renamed_argument("get_raw_response", None, since="0.4.7",
alternative="async methods")
def elements_async(self, get_query_payload=False,
refsystem='ICRF',
refplane='ecliptic',
Expand All @@ -641,6 +649,10 @@ def elements_async(self, get_query_payload=False,
"""
Query JPL Horizons for osculating orbital elements.
.. deprecated:: 0.4.7
The ``get_raw_response`` keyword argument is deprecated. The
`~HorizonsClass.elements_async` method will return a raw response.
The ``location`` parameter in ``HorizonsClass`` refers in this case to
the center body relative to which the elements are provided.
Expand Down Expand Up @@ -850,6 +862,8 @@ def elements_async(self, get_query_payload=False,

return response

@deprecated_renamed_argument("get_raw_response", None, since="0.4.7",
alternative="async methods")
def vectors_async(self, get_query_payload=False,
closest_apparition=False, no_fragments=False,
get_raw_response=False, cache=True,
Expand All @@ -858,6 +872,10 @@ def vectors_async(self, get_query_payload=False,
"""
Query JPL Horizons for state vectors.
.. deprecated:: 0.4.7
The ``get_raw_response`` keyword argument is deprecated. The
`~HorizonsClass.vectors_async` method will return a raw response.
The ``location`` parameter in ``HorizonsClass`` refers in this case to
the center body relative to which the vectors are provided.
Expand Down
36 changes: 24 additions & 12 deletions astroquery/jplhorizons/tests/test_jplhorizons_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@


import pytest
from astropy.tests.helper import assert_quantity_allclose
from numpy.ma import is_masked

from astropy.tests.helper import assert_quantity_allclose
from astropy.utils.exceptions import AstropyDeprecationWarning

from ... import jplhorizons


Expand Down Expand Up @@ -175,9 +177,13 @@ def test_ephemerides_query_six(self):
assert len(res) == 32

def test_ephemerides_query_raw(self):
res = (jplhorizons.Horizons(id='Ceres', location='500',
id_type='smallbody', epochs=2451544.5).
ephemerides(get_raw_response=True))
# deprecated as of #2418
with pytest.warns(AstropyDeprecationWarning):
res = (jplhorizons.Horizons(id='Ceres',
location='500',
id_type='smallbody',
epochs=2451544.5)
.ephemerides(get_raw_response=True))

assert len(res) >= 15400

Expand Down Expand Up @@ -227,10 +233,13 @@ def test_elements_query_two(self):
rtol=1e-3)

def test_elements_query_raw(self):
res = jplhorizons.Horizons(id='Ceres', location='500@10',
id_type='smallbody',
epochs=2451544.5).elements(
get_raw_response=True)
# deprecated as of #2418
with pytest.warns(AstropyDeprecationWarning):
res = (jplhorizons.Horizons(id='Ceres',
location='500@10',
id_type='smallbody',
epochs=2451544.5)
.elements(get_raw_response=True))

assert len(res) >= 6686

Expand Down Expand Up @@ -261,10 +270,13 @@ def test_vectors_query(self):
res['range_rate']], rtol=1e-3)

def test_vectors_query_raw(self):
res = jplhorizons.Horizons(id='Ceres', location='500@10',
id_type='smallbody',
epochs=2451544.5).vectors(
get_raw_response=True)
# deprecated as of #2418
with pytest.warns(AstropyDeprecationWarning):
res = (jplhorizons.Horizons(id='Ceres',
location='500@10',
id_type='smallbody',
epochs=2451544.5)
.vectors(get_raw_response=True))

assert len(res) >= 6412

Expand Down
14 changes: 5 additions & 9 deletions docs/jplhorizons/jplhorizons.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ limits fragment matching (73P-B would only match 73P-B), respectively. Note
that these options should only be used for comets and will crash the query for
other object types. Extra precision in the queried properties can be requested
using the ``extra_precision`` option. Furthermore, ``get_query_payload=True``
skips the query and only returns the query payload, whereas
``get_raw_response=True`` returns the raw query response instead of the astropy
table.
skips the query and only returns the query payload.

:meth:`~astroquery.jplhorizons.HorizonsClass.ephemerides` queries by default all
available quantities from the JPL Horizons servers. This might take a while. If
Expand Down Expand Up @@ -243,9 +241,8 @@ absolute representation of the time of perihelion passage. For comets, the
options ``closest_apparition`` and ``no_fragments`` are available, which select
the closest apparition in time and reject fragments, respectively. Note that
these options should only be used for comets and will crash the query for other
object types. Also available are ``get_query_payload=True``, which skips the
query and only returns the query payload, and ``get_raw_response=True``, which
returns the raw query response instead of the astropy table.
object types. Also available is ``get_query_payload=True``, which skips the
query and only returns the query payload.

Vectors
-------
Expand Down Expand Up @@ -290,10 +287,9 @@ The following fields are queried:
Similar to the other :class:`~astroquery.jplhorizons.HorizonsClass` functions,
optional parameters of :meth:`~astroquery.jplhorizons.HorizonsClass.vectors` are
optional parameters of :meth:`~astroquery.jplhorizons.HorizonsClass.vectors` is
``get_query_payload=True``, which skips the query and only returns the query
payload, and ``get_raw_response=True``, which returns the raw query response
instead of the astropy table. For comets, the options ``closest_apparation`` and
payload. For comets, the options ``closest_apparation`` and
``no_fragments`` are available, which select the closest apparition in time and
reject fragments, respectively. Note that these options should only be used for
comets and will crash the query for other object types. Options ``aberrations``
Expand Down

0 comments on commit 21844a7

Please sign in to comment.