Skip to content

Commit 3116180

Browse files
committed
Raise deprecation warnings for id_type=majorbody and id.
1 parent 80f5f1c commit 3116180

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

astroquery/jplhorizons/core.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from astropy.table import Table, Column
1313
from astropy.io import ascii
1414
from astropy.time import Time
15+
from astropy.utils.exceptions import AstropyDeprecationWarning
1516

1617
# 3. local imports - use relative imports
1718
# commonly required local imports shown below as example
@@ -108,7 +109,11 @@ def __init__(self, id=None, location=None, epochs=None,
108109
self.epochs = epochs
109110

110111
# check for id_type
111-
112+
if id_type in ['majorbody', 'id']:
113+
warnings.warn("``id_type``s 'majorbody' and 'id' are deprecated "
114+
"and replaced with ``None``, which has the same "
115+
"functionality.", AstropyDeprecationWarning)
116+
id_type = None
112117
if id_type not in [None, 'smallbody', 'designation', 'name',
113118
'asteroid_name', 'comet_name']:
114119
raise ValueError('id_type ({:s}) not allowed'.format(id_type))

astroquery/jplhorizons/tests/test_jplhorizons.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,17 @@ def test_no_H(patch_request):
219219
"""testing missing H value (also applies for G, M1, k1, M2, k2)"""
220220
res = jplhorizons.Horizons(id='1935 UZ').ephemerides()[0]
221221
assert 'H' not in res
222+
223+
224+
def test_id_type_deprecation():
225+
"""Test deprecation warnings based on issue 1742.
226+
227+
 https://github.com/astropy/astroquery/pull/2161
228+
229+
"""
230+
231+
with pytest.warns(AstropyDeprecationWarning):
232+
res = jplhorizons.Horizons(id='Ceres', id_type='id')
233+
234+
with pytest.warns(AstropyDeprecationWarning):
235+
res = jplhorizons.Horizons(id='Ceres', id_type='majorbody')

0 commit comments

Comments
 (0)