Skip to content

Commit 8064473

Browse files
authored
Merge pull request astropy#3607 from karlhillx/fix-3605-naifid-typo
Fix NAIF ID typos in Most: nafid -> naifid
2 parents 6fa144d + b98c2bb commit 8064473

3 files changed

Lines changed: 69 additions & 13 deletions

File tree

CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ imcce
132132
- Change the URL for SkyBot and Miriade Web Services [#3595]
133133
- Adapted the ``Miriade`` Class to the new outputs of the Web Service [#3595]
134134

135+
ipac.irsa
136+
^^^^^^^^^
137+
138+
- Fix NAIF ID input mode in ``Most``: the parameter and value ``nafid``
139+
were typos; the API expects ``naifid``. Old ``obj_nafid`` keyword and
140+
``"nafid_input"`` ``input_mode`` still work but emit
141+
``AstropyDeprecationWarning``. [#3607]
142+
135143

136144
mast
137145
^^^^

astroquery/ipac/irsa/most.py

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
from astropy.io import votable, fits
99
from astropy.table import Table
10+
from astropy.utils.decorators import deprecated_renamed_argument
11+
from astropy.utils.exceptions import AstropyDeprecationWarning
1012

1113
from astroquery.query import BaseQuery
1214
from astroquery.utils import class_or_instance
@@ -56,8 +58,8 @@ def _validate_nafid_input_type(self, params):
5658
If the input does not have the minimum required parameters set to
5759
an at least truthy value.
5860
"""
59-
if not params.get("obj_nafid", False):
60-
raise ValueError("When input type is 'nafid_input' key 'obj_nafid' is required.")
61+
if not params.get("obj_naifid", False):
62+
raise ValueError("When input type is 'naifid_input' key 'obj_naifid' is required.")
6163

6264
def _validate_mpc_input_type(self, params):
6365
"""
@@ -148,15 +150,15 @@ def _validate_input(self, params):
148150

149151
if input_type == "name_input":
150152
self._validate_name_input_type(params)
151-
elif input_type == "nafid_input":
153+
elif input_type == "naifid_input":
152154
self._validate_nafid_input_type(params)
153155
elif input_type == "mpc_input":
154156
self._validate_mpc_input_type(params)
155157
elif input_type == "manual_input":
156158
self._validate_manual_input_type(params)
157159
else:
158160
raise ValueError(
159-
"Unrecognized 'input_type'. Expected `name_input`, `nafid_input` "
161+
"Unrecognized 'input_type'. Expected `name_input`, `naifid_input` "
160162
f"`mpc_input` or `manual_input`, got {input_type} instead."
161163
)
162164

@@ -229,8 +231,9 @@ def list_catalogs(self):
229231
catalogs.remove("--- Internal use only:")
230232
return catalogs
231233

234+
@deprecated_renamed_argument('obj_nafid', 'obj_naifid', since='0.4.12')
232235
def get_images(self, catalog="wise_merge", input_mode="name_input", ephem_step=0.25,
233-
obs_begin=None, obs_end=None, obj_name=None, obj_nafid=None, obj_type=None,
236+
obs_begin=None, obs_end=None, obj_name=None, obj_naifid=None, obj_type=None,
234237
mpc_data=None, body_designation=None, epoch=None, eccentricity=None,
235238
inclination=None, arg_perihelion=None, ascend_node=None, semimajor_axis=None,
236239
mean_anomaly=None, perih_dist=None, perih_time=None, get_query_payload=False,
@@ -268,8 +271,8 @@ def get_images(self, catalog="wise_merge", input_mode="name_input", ephem_step=0
268271
obj_name : str or None
269272
Object name.
270273
Required when input mode is ``"name_input"``.
271-
obj_nafid : str or None
272-
Object NAIFD.
274+
obj_naifid : str or None
275+
Object NAIF ID.
273276
Required when input mode is ``"naifid_input"``.
274277
obj_type : str or None
275278
Object type, ``"Asteroid"`` or ``Comet``.
@@ -328,6 +331,14 @@ def get_images(self, catalog="wise_merge", input_mode="name_input", ephem_step=0
328331
images : list
329332
A list of `~astropy.io.fits.HDUList` objects.
330333
"""
334+
if input_mode == "nafid_input":
335+
warnings.warn(
336+
"'nafid_input' is deprecated; use 'naifid_input' instead (the API value is 'naifid_input').",
337+
AstropyDeprecationWarning,
338+
stacklevel=2,
339+
)
340+
input_mode = "naifid_input"
341+
331342
# We insist on output_mode being regular so that it executes quicker,
332343
# and we insist on tarballs so the download is quicker. We ignore
333344
# whatever else user provides, but leave the parameters as arguments to
@@ -339,7 +350,7 @@ def get_images(self, catalog="wise_merge", input_mode="name_input", ephem_step=0
339350
obs_end=obs_end,
340351
ephem_step=ephem_step,
341352
obj_name=obj_name,
342-
obj_nafid=obj_nafid,
353+
obj_naifid=obj_naifid,
343354
obj_type=obj_type,
344355
mpc_data=mpc_data,
345356
body_designation=body_designation,
@@ -376,9 +387,10 @@ def get_images(self, catalog="wise_merge", input_mode="name_input", ephem_step=0
376387
return images
377388

378389
@class_or_instance
390+
@deprecated_renamed_argument('obj_nafid', 'obj_naifid', since='0.4.12')
379391
def query_object(self, catalog="wise_merge", input_mode="name_input", output_mode="Regular",
380392
ephem_step=0.25, with_tarballs=False, obs_begin=None, obs_end=None,
381-
obj_name=None, obj_nafid=None, obj_type=None, mpc_data=None,
393+
obj_name=None, obj_naifid=None, obj_type=None, mpc_data=None,
382394
body_designation=None, epoch=None, eccentricity=None, inclination=None,
383395
arg_perihelion=None, ascend_node=None, semimajor_axis=None, mean_anomaly=None,
384396
perih_dist=None, perih_time=None, get_query_payload=False):
@@ -437,8 +449,8 @@ def query_object(self, catalog="wise_merge", input_mode="name_input", output_mod
437449
obj_name : str or None
438450
Object name.
439451
Required when input mode is ``"name_input"``.
440-
obj_nafid : str or None
441-
Object NAIFD
452+
obj_naifid : str or None
453+
Object NAIF ID.
442454
Required when input mode is ``"naifid_input"``.
443455
obj_type : str or None
444456
Object type, ``"Asteroid"`` or ``Comet``
@@ -498,6 +510,14 @@ def query_object(self, catalog="wise_merge", input_mode="name_input", output_mod
498510
in ``"VOTable"`` an `~astropy.io.votable.tree.VOTableFile`. See
499511
module help for more details on the content of these tables.
500512
"""
513+
if input_mode == "nafid_input":
514+
warnings.warn(
515+
"'nafid_input' is deprecated; use 'naifid_input' instead (the API value is 'naifid_input').",
516+
AstropyDeprecationWarning,
517+
stacklevel=2,
518+
)
519+
input_mode = "naifid_input"
520+
501521
# This is a map between the keyword names used by the MOST cgi-bin
502522
# service and their more user-friendly names. For example,
503523
# input_type -> input_mode or fits_region_files --> with tarballs
@@ -510,7 +530,7 @@ def query_object(self, catalog="wise_merge", input_mode="name_input", output_mod
510530
"ephem_step": ephem_step,
511531
"fits_region_files": "on" if with_tarballs else "",
512532
"obj_name": obj_name,
513-
"obj_nafid": obj_nafid,
533+
"obj_naifid": obj_naifid,
514534
"obj_type": obj_type,
515535
"mpc_data": mpc_data,
516536
"body_designation": body_designation,

astroquery/ipac/irsa/tests/test_most.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
from astropy.io import votable
88
from astropy.table import Table
9+
from astropy.utils.diff import report_diff_values
10+
from astropy.utils.exceptions import AstropyDeprecationWarning
911
from astroquery.utils.mocks import MockResponse
1012
from astroquery.ipac.irsa import Most
11-
from astropy.utils.diff import report_diff_values
1213

1314

1415
# each MOST query is given a PID and a temporary directory availible publicly
@@ -248,3 +249,30 @@ def test_gator(patch_requests):
248249
tbl = Table.read(data_path("most_gator.tbl"), format="ipac")
249250
silent_stream = io.StringIO()
250251
assert report_diff_values(tbl, response, silent_stream)
252+
253+
254+
def test_naifid_input(patch_requests):
255+
"""NAIF ID input mode works with the correct 'naifid_input' spelling."""
256+
response = Most.query_object(
257+
obj_naifid="606",
258+
input_mode="naifid_input",
259+
output_mode="Brief",
260+
)
261+
assert len(response) > 0
262+
263+
264+
def test_nafid_deprecation(patch_requests):
265+
"""Deprecated 'obj_nafid' and 'nafid_input' emit AstropyDeprecationWarning."""
266+
with pytest.warns(AstropyDeprecationWarning, match="obj_nafid"):
267+
Most.query_object(
268+
obj_nafid="606",
269+
input_mode="naifid_input",
270+
output_mode="Brief",
271+
)
272+
273+
with pytest.warns(AstropyDeprecationWarning, match="naifid_input"):
274+
Most.query_object(
275+
obj_naifid="606",
276+
input_mode="nafid_input",
277+
output_mode="Brief",
278+
)

0 commit comments

Comments
 (0)