Skip to content

Commit e5d2c8e

Browse files
authored
Merge pull request #2609 from keflavich/simbad_kwargonly
Refactor: SIMBAD keyword-only
2 parents 0cc58b7 + 64dd0b7 commit e5d2c8e

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ simbad
135135
- It is now possible to specify multiple coordinates together with a single
136136
radius as a string in ``query_region()`` and ``query_region_async()``.
137137
[#2494]
138+
- Optional keyword arguments are now keyword only. [#2609]
138139

139140
skyview
140141
^^^^^^^

astroquery/simbad/core.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def query_criteria_async(self, *args, **kwargs):
500500
timeout=self.TIMEOUT, cache=cache)
501501
return response
502502

503-
def query_object(self, object_name, wildcard=False, verbose=False,
503+
def query_object(self, object_name, *, wildcard=False, verbose=False,
504504
get_query_payload=False):
505505
"""
506506
Queries Simbad for the given object and returns the result as a
@@ -531,7 +531,7 @@ def query_object(self, object_name, wildcard=False, verbose=False,
531531
return self._parse_result(response, SimbadVOTableResult,
532532
verbose=verbose)
533533

534-
def query_object_async(self, object_name, wildcard=False, cache=True,
534+
def query_object_async(self, object_name, *, wildcard=False, cache=True,
535535
get_query_payload=False):
536536

537537
"""
@@ -564,7 +564,7 @@ def query_object_async(self, object_name, wildcard=False, cache=True,
564564
timeout=self.TIMEOUT, cache=cache)
565565
return response
566566

567-
def query_objects(self, object_names, wildcard=False, verbose=False,
567+
def query_objects(self, object_names, *, wildcard=False, verbose=False,
568568
get_query_payload=False):
569569
"""
570570
Queries Simbad for the specified list of objects and returns the
@@ -590,7 +590,7 @@ def query_objects(self, object_names, wildcard=False, verbose=False,
590590
return self.query_object('\n'.join(object_names), wildcard=wildcard,
591591
get_query_payload=get_query_payload)
592592

593-
def query_objects_async(self, object_names, wildcard=False, cache=True,
593+
def query_objects_async(self, object_names, *, wildcard=False, cache=True,
594594
get_query_payload=False):
595595
"""
596596
Same as `query_objects`, but only collects the response from the
@@ -616,7 +616,7 @@ def query_objects_async(self, object_names, wildcard=False, cache=True,
616616
wildcard=wildcard, cache=cache,
617617
get_query_payload=get_query_payload)
618618

619-
def query_region_async(self, coordinates, radius=2*u.arcmin,
619+
def query_region_async(self, coordinates, radius=2*u.arcmin, *,
620620
equinox=2000.0, epoch='J2000', cache=True,
621621
get_query_payload=False):
622622
"""
@@ -627,9 +627,8 @@ def query_region_async(self, coordinates, radius=2*u.arcmin,
627627
----------
628628
coordinates : str or `astropy.coordinates` object
629629
the identifier or coordinates around which to query.
630-
radius : str or `~astropy.units.Quantity`, optional
631-
the radius of the region. If missing, set to default
632-
value of 2 arcmin.
630+
radius : str or `~astropy.units.Quantity`
631+
the radius of the region. Defaults to 2 arcmin.
633632
equinox : float, optional
634633
the equinox of the coordinates. If missing set to
635634
default 2000.0.
@@ -646,14 +645,15 @@ def query_region_async(self, coordinates, radius=2*u.arcmin,
646645
Response of the query from the server.
647646
"""
648647

648+
if radius is None:
649+
# this message is specifically for deprecated use of 'None' to mean 'Default'
650+
raise ValueError("Radius must be specified as an angle-equivalent quantity, not None")
651+
649652
equinox = validate_equinox(equinox)
650653
epoch = validate_epoch(epoch)
651654

652655
base_query_str = "query coo {ra} {dec} radius={rad} frame={frame} equi={equinox}"
653656

654-
if radius is None:
655-
radius = 2*u.arcmin
656-
657657
header = self._get_query_header()
658658
footer = self._get_query_footer()
659659

@@ -698,7 +698,7 @@ def query_region_async(self, coordinates, radius=2*u.arcmin,
698698
timeout=self.TIMEOUT, cache=cache)
699699
return response
700700

701-
def query_catalog(self, catalog, verbose=False, cache=True,
701+
def query_catalog(self, catalog, *, verbose=False, cache=True,
702702
get_query_payload=False):
703703
"""
704704
Queries a whole catalog.
@@ -727,7 +727,7 @@ def query_catalog(self, catalog, verbose=False, cache=True,
727727
return self._parse_result(response, SimbadVOTableResult,
728728
verbose=verbose)
729729

730-
def query_catalog_async(self, catalog, cache=True, get_query_payload=False):
730+
def query_catalog_async(self, catalog, *, cache=True, get_query_payload=False):
731731
"""
732732
Serves the same function as `query_catalog`, but
733733
only collects the response from the Simbad server and returns.
@@ -755,7 +755,7 @@ def query_catalog_async(self, catalog, cache=True, get_query_payload=False):
755755
timeout=self.TIMEOUT, cache=cache)
756756
return response
757757

758-
def query_bibobj(self, bibcode, verbose=False, get_query_payload=False):
758+
def query_bibobj(self, bibcode, *, verbose=False, get_query_payload=False):
759759
"""
760760
Query all the objects that are contained in the article specified by
761761
the bibcode, and return results as a `~astropy.table.Table`.
@@ -781,7 +781,7 @@ def query_bibobj(self, bibcode, verbose=False, get_query_payload=False):
781781
return self._parse_result(response, SimbadVOTableResult,
782782
verbose=verbose)
783783

784-
def query_bibobj_async(self, bibcode, cache=True, get_query_payload=False):
784+
def query_bibobj_async(self, bibcode, *, cache=True, get_query_payload=False):
785785
"""
786786
Serves the same function as `query_bibobj`, but only collects the
787787
response from the Simbad server and returns.
@@ -809,7 +809,7 @@ def query_bibobj_async(self, bibcode, cache=True, get_query_payload=False):
809809
timeout=self.TIMEOUT, cache=cache)
810810
return response
811811

812-
def query_bibcode(self, bibcode, wildcard=False, verbose=False,
812+
def query_bibcode(self, bibcode, *, wildcard=False, verbose=False,
813813
cache=True, get_query_payload=False):
814814
"""
815815
Queries the references corresponding to a given bibcode, and returns
@@ -843,7 +843,7 @@ def query_bibcode(self, bibcode, wildcard=False, verbose=False,
843843
return self._parse_result(response, SimbadBibcodeResult,
844844
verbose=verbose)
845845

846-
def query_bibcode_async(self, bibcode, wildcard=False, cache=True,
846+
def query_bibcode_async(self, bibcode, *, wildcard=False, cache=True,
847847
get_query_payload=False):
848848
"""
849849
Serves the same function as `query_bibcode`, but
@@ -878,7 +878,7 @@ def query_bibcode_async(self, bibcode, wildcard=False, cache=True,
878878

879879
return response
880880

881-
def query_objectids(self, object_name, verbose=False, cache=True,
881+
def query_objectids(self, object_name, *, verbose=False, cache=True,
882882
get_query_payload=False):
883883
"""
884884
Query Simbad with an object name, and return a table of all
@@ -906,7 +906,7 @@ def query_objectids(self, object_name, verbose=False, cache=True,
906906
return self._parse_result(response, SimbadObjectIDsResult,
907907
verbose=verbose)
908908

909-
def query_objectids_async(self, object_name, cache=True,
909+
def query_objectids_async(self, object_name, *, cache=True,
910910
get_query_payload=False):
911911
"""
912912
Serves the same function as `query_objectids`, but

astroquery/simbad/tests/test_simbad.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,10 @@ def test_query_catalog(patch_post):
234234

235235

236236
@pytest.mark.parametrize(('coordinates', 'radius', 'equinox', 'epoch'),
237-
[(ICRS_COORDS, None, 2000.0, 'J2000'),
237+
[(ICRS_COORDS, 2*u.arcmin, 2000.0, 'J2000'),
238238
(GALACTIC_COORDS, 5 * u.deg, 2000.0, 'J2000'),
239239
(FK4_COORDS, '5d0m0s', 2000.0, 'J2000'),
240-
(FK5_COORDS, None, 2000.0, 'J2000'),
240+
(FK5_COORDS, 2*u.arcmin, 2000.0, 'J2000'),
241241
(multicoords, 0.5*u.arcsec, 2000.0, 'J2000'),
242242
(multicoords, "0.5s", 2000.0, 'J2000'),
243243
])
@@ -253,10 +253,10 @@ def test_query_region_async(patch_post, coordinates, radius, equinox, epoch):
253253

254254

255255
@pytest.mark.parametrize(('coordinates', 'radius', 'equinox', 'epoch'),
256-
[(ICRS_COORDS, None, 2000.0, 'J2000'),
256+
[(ICRS_COORDS, 2*u.arcmin, 2000.0, 'J2000'),
257257
(GALACTIC_COORDS, 5 * u.deg, 2000.0, 'J2000'),
258258
(FK4_COORDS, '5d0m0s', 2000.0, 'J2000'),
259-
(FK5_COORDS, None, 2000.0, 'J2000')
259+
(FK5_COORDS, 2*u.arcmin, 2000.0, 'J2000')
260260
])
261261
def test_query_region(patch_post, coordinates, radius, equinox, epoch):
262262
result1 = simbad.core.Simbad.query_region(coordinates, radius=radius,

0 commit comments

Comments
 (0)