Skip to content

Commit 21844a7

Browse files
committed
Deprecate get_raw_response.
1 parent 55642bc commit 21844a7

File tree

3 files changed

+48
-22
lines changed

3 files changed

+48
-22
lines changed

astroquery/jplhorizons/core.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from astropy.io import ascii
1515
from astropy.time import Time
1616
from astropy.utils.exceptions import AstropyDeprecationWarning
17+
from astropy.utils.decorators import deprecated_renamed_argument
1718

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

166167
# ---------------------------------- query functions
167168

169+
@deprecated_renamed_argument("get_raw_response", None, since="0.4.7",
170+
alternative="async methods")
168171
def ephemerides_async(self, airmass_lessthan=99,
169172
solar_elongation=(0, 180), max_hour_angle=0,
170173
rate_cutoff=None,
@@ -179,6 +182,10 @@ def ephemerides_async(self, airmass_lessthan=99,
179182
"""
180183
Query JPL Horizons for ephemerides.
181184
185+
.. deprecated:: 0.4.7
186+
The ``get_raw_response`` keyword argument is deprecated. The
187+
`~HorizonsClass.ephemerides_async` method will return a raw response.
188+
182189
The ``location`` parameter in ``HorizonsClass`` refers in this case to
183190
the location of the observer.
184191
@@ -492,7 +499,6 @@ def ephemerides_async(self, airmass_lessthan=99,
492499
response : `requests.Response`
493500
The response of the HTTP request.
494501
495-
496502
Examples
497503
--------
498504
@@ -632,6 +638,8 @@ def ephemerides_async(self, airmass_lessthan=99,
632638

633639
return response
634640

641+
@deprecated_renamed_argument("get_raw_response", None, since="0.4.7",
642+
alternative="async methods")
635643
def elements_async(self, get_query_payload=False,
636644
refsystem='ICRF',
637645
refplane='ecliptic',
@@ -641,6 +649,10 @@ def elements_async(self, get_query_payload=False,
641649
"""
642650
Query JPL Horizons for osculating orbital elements.
643651
652+
.. deprecated:: 0.4.7
653+
The ``get_raw_response`` keyword argument is deprecated. The
654+
`~HorizonsClass.elements_async` method will return a raw response.
655+
644656
The ``location`` parameter in ``HorizonsClass`` refers in this case to
645657
the center body relative to which the elements are provided.
646658
@@ -850,6 +862,8 @@ def elements_async(self, get_query_payload=False,
850862

851863
return response
852864

865+
@deprecated_renamed_argument("get_raw_response", None, since="0.4.7",
866+
alternative="async methods")
853867
def vectors_async(self, get_query_payload=False,
854868
closest_apparition=False, no_fragments=False,
855869
get_raw_response=False, cache=True,
@@ -858,6 +872,10 @@ def vectors_async(self, get_query_payload=False,
858872
"""
859873
Query JPL Horizons for state vectors.
860874
875+
.. deprecated:: 0.4.7
876+
The ``get_raw_response`` keyword argument is deprecated. The
877+
`~HorizonsClass.vectors_async` method will return a raw response.
878+
861879
The ``location`` parameter in ``HorizonsClass`` refers in this case to
862880
the center body relative to which the vectors are provided.
863881

astroquery/jplhorizons/tests/test_jplhorizons_remote.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33

44
import pytest
5-
from astropy.tests.helper import assert_quantity_allclose
65
from numpy.ma import is_masked
76

7+
from astropy.tests.helper import assert_quantity_allclose
8+
from astropy.utils.exceptions import AstropyDeprecationWarning
9+
810
from ... import jplhorizons
911

1012

@@ -175,9 +177,13 @@ def test_ephemerides_query_six(self):
175177
assert len(res) == 32
176178

177179
def test_ephemerides_query_raw(self):
178-
res = (jplhorizons.Horizons(id='Ceres', location='500',
179-
id_type='smallbody', epochs=2451544.5).
180-
ephemerides(get_raw_response=True))
180+
# deprecated as of #2418
181+
with pytest.warns(AstropyDeprecationWarning):
182+
res = (jplhorizons.Horizons(id='Ceres',
183+
location='500',
184+
id_type='smallbody',
185+
epochs=2451544.5)
186+
.ephemerides(get_raw_response=True))
181187

182188
assert len(res) >= 15400
183189

@@ -227,10 +233,13 @@ def test_elements_query_two(self):
227233
rtol=1e-3)
228234

229235
def test_elements_query_raw(self):
230-
res = jplhorizons.Horizons(id='Ceres', location='500@10',
231-
id_type='smallbody',
232-
epochs=2451544.5).elements(
233-
get_raw_response=True)
236+
# deprecated as of #2418
237+
with pytest.warns(AstropyDeprecationWarning):
238+
res = (jplhorizons.Horizons(id='Ceres',
239+
location='500@10',
240+
id_type='smallbody',
241+
epochs=2451544.5)
242+
.elements(get_raw_response=True))
234243

235244
assert len(res) >= 6686
236245

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

263272
def test_vectors_query_raw(self):
264-
res = jplhorizons.Horizons(id='Ceres', location='500@10',
265-
id_type='smallbody',
266-
epochs=2451544.5).vectors(
267-
get_raw_response=True)
273+
# deprecated as of #2418
274+
with pytest.warns(AstropyDeprecationWarning):
275+
res = (jplhorizons.Horizons(id='Ceres',
276+
location='500@10',
277+
id_type='smallbody',
278+
epochs=2451544.5)
279+
.vectors(get_raw_response=True))
268280

269281
assert len(res) >= 6412
270282

docs/jplhorizons/jplhorizons.rst

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ limits fragment matching (73P-B would only match 73P-B), respectively. Note
189189
that these options should only be used for comets and will crash the query for
190190
other object types. Extra precision in the queried properties can be requested
191191
using the ``extra_precision`` option. Furthermore, ``get_query_payload=True``
192-
skips the query and only returns the query payload, whereas
193-
``get_raw_response=True`` returns the raw query response instead of the astropy
194-
table.
192+
skips the query and only returns the query payload.
195193

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

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

0 commit comments

Comments
 (0)