Skip to content

Commit 6ee7784

Browse files
committed
make kwargs mandatory
1 parent b7e2d79 commit 6ee7784

File tree

6 files changed

+37
-25
lines changed

6 files changed

+37
-25
lines changed

astroquery/mast/collections.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def query_object_async(self, objectname, *, radius=0.2*u.deg, catalog="Hsc",
344344
response : list of `~requests.Response`
345345
"""
346346

347-
coordinates = utils.resolve_object(objectname, resolver)
347+
coordinates = utils.resolve_object(objectname, resolver=resolver)
348348

349349
return self.query_region_async(coordinates,
350350
radius=radius,
@@ -405,7 +405,9 @@ def query_criteria_async(self, catalog, *, pagesize=None, page=None, resolver=No
405405
radius = criteria.pop('radius', 0.2*u.deg)
406406

407407
if objectname or coordinates:
408-
coordinates = utils.parse_input_location(coordinates, objectname, resolver)
408+
coordinates = utils.parse_input_location(coordinates=coordinates,
409+
objectname=objectname,
410+
resolver=resolver)
409411

410412
# if radius is just a number we assume degrees
411413
radius = coord.Angle(radius, u.deg)

astroquery/mast/core.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def disable_cloud_dataset(self):
110110
"""
111111
pass
112112

113-
def resolve_object(self, objectname, resolver=None, resolve_all=False):
113+
def resolve_object(self, objectname, *, resolver=None, resolve_all=False):
114114
"""
115115
Resolves an object name to a position on the sky.
116116
@@ -135,4 +135,6 @@ def resolve_object(self, objectname, resolver=None, resolve_all=False):
135135
If ``resolve_all`` is True, returns a dictionary where the keys are the resolver names and the values are
136136
`~astropy.coordinates.SkyCoord` objects with the resolved coordinates.
137137
"""
138-
return utils.resolve_object(objectname, resolver, resolve_all)
138+
return utils.resolve_object(objectname,
139+
resolver=resolver,
140+
resolve_all=resolve_all)

astroquery/mast/cutouts.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ def get_sectors(self, *, coordinates=None, radius=0*u.deg, product='SPOC', objec
192192
else:
193193

194194
# Get Skycoord object for coordinates/object
195-
coordinates = parse_input_location(coordinates, objectname, resolver)
195+
coordinates = parse_input_location(coordinates=coordinates,
196+
objectname=objectname,
197+
resolver=resolver)
196198

197199
# If radius is just a number we assume degrees
198200
radius = Angle(radius, u.deg)
@@ -321,7 +323,9 @@ def download_cutouts(self, *, coordinates=None, size=5, sector=None, product='SP
321323
else:
322324

323325
# Get Skycoord object for coordinates/object
324-
coordinates = parse_input_location(coordinates, objectname, resolver)
326+
coordinates = parse_input_location(coordinates=coordinates,
327+
objectname=objectname,
328+
resolver=resolver)
325329

326330
astrocut_request = f"astrocut?ra={coordinates.ra.deg}&dec={coordinates.dec.deg}"
327331

@@ -473,7 +477,9 @@ def get_cutouts(self, *, coordinates=None, size=5, product='SPOC', sector=None,
473477
param_dict['product'] = product.upper()
474478

475479
# Get Skycoord object for coordinates/object
476-
coordinates = parse_input_location(coordinates, objectname, resolver)
480+
coordinates = parse_input_location(coordinates=coordinates,
481+
objectname=objectname,
482+
resolver=resolver)
477483

478484
param_dict["ra"] = coordinates.ra.deg
479485
param_dict["dec"] = coordinates.dec.deg
@@ -547,7 +553,7 @@ def get_surveys(self, coordinates, *, radius="0d"):
547553
"""
548554

549555
# Get Skycoord object for coordinates/object
550-
coordinates = parse_input_location(coordinates)
556+
coordinates = parse_input_location(coordinates=coordinates)
551557
radius = Angle(radius, u.deg)
552558

553559
params = {"ra": coordinates.ra.deg,
@@ -612,7 +618,7 @@ def download_cutouts(self, coordinates, *, size=5, survey=None, cutout_format="f
612618
Cutout file(s) for given coordinates
613619
"""
614620
# Get Skycoord object for coordinates/object
615-
coordinates = parse_input_location(coordinates)
621+
coordinates = parse_input_location(coordinates=coordinates)
616622
size_dict = _parse_cutout_size(size)
617623

618624
path = os.path.join(path, '')
@@ -691,7 +697,7 @@ def get_cutouts(self, coordinates, *, size=5, survey=None):
691697
"""
692698

693699
# Get Skycoord object for coordinates/object
694-
coordinates = parse_input_location(coordinates)
700+
coordinates = parse_input_location(coordinates=coordinates)
695701

696702
param_dict = _parse_cutout_size(size)
697703
param_dict["ra"] = coordinates.ra.deg
@@ -776,7 +782,7 @@ def download_cutouts(self, coordinates, *, size=5, path=".", inflate=True, verbo
776782
"""
777783

778784
# Get Skycoord object for coordinates/object
779-
coordinates = parse_input_location(coordinates)
785+
coordinates = parse_input_location(coordinates=coordinates)
780786

781787
# Build initial astrocut request
782788
astrocut_request = f"astrocut?ra={coordinates.ra.deg}&dec={coordinates.dec.deg}"
@@ -845,7 +851,7 @@ def get_cutouts(self, coordinates, *, size=5):
845851
"""
846852

847853
# Get Skycoord object for coordinates/object
848-
coordinates = parse_input_location(coordinates)
854+
coordinates = parse_input_location(coordinates=coordinates)
849855

850856
param_dict = _parse_cutout_size(size)
851857

astroquery/mast/missions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,9 @@ def query_criteria_async(self, *, coordinates=None, objectname=None, radius=3*u.
273273

274274
# Parse user input location
275275
if objectname or coordinates:
276-
coordinates = utils.parse_input_location(coordinates, objectname, resolver)
276+
coordinates = utils.parse_input_location(coordinates=coordinates,
277+
objectname=objectname,
278+
resolver=resolver)
277279

278280
# if radius is just a number we assume degrees
279281
radius = coord.Angle(radius, u.arcmin)
@@ -342,7 +344,7 @@ def query_object_async(self, objectname, *, radius=3*u.arcmin, limit=5000, offse
342344
response : list of `~requests.Response`
343345
"""
344346

345-
coordinates = utils.resolve_object(objectname, resolver)
347+
coordinates = utils.resolve_object(objectname, resolver=resolver)
346348

347349
return self.query_region_async(coordinates, radius=radius, limit=limit, offset=offset,
348350
select_cols=select_cols, **criteria)

astroquery/mast/observations.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def get_metadata(self, query_type):
119119

120120
return self._portal_api_connection._get_columnsconfig_metadata(colconf_name)
121121

122-
def _parse_caom_criteria(self, resolver=None, **criteria):
122+
def _parse_caom_criteria(self, *, resolver=None, **criteria):
123123
"""
124124
Helper function that takes dictionary of criteria and parses them into
125125
position (none if there are no coordinates/object name) and a filter set.
@@ -159,7 +159,9 @@ def _parse_caom_criteria(self, resolver=None, **criteria):
159159
mashup_filters = self._portal_api_connection.build_filter_set(self._caom_cone,
160160
self._caom_filtered_position,
161161
**criteria)
162-
coordinates = utils.parse_input_location(coordinates, objectname, resolver)
162+
coordinates = utils.parse_input_location(coordinates=coordinates,
163+
objectname=objectname,
164+
resolver=resolver)
163165
else:
164166
mashup_filters = self._portal_api_connection.build_filter_set(self._caom_cone,
165167
self._caom_filtered,
@@ -278,7 +280,7 @@ def query_object_async(self, objectname, *, radius=0.2*u.deg, pagesize=None, pag
278280
response : list of `~requests.Response`
279281
"""
280282

281-
coordinates = utils.resolve_object(objectname, resolver)
283+
coordinates = utils.resolve_object(objectname, resolver=resolver)
282284

283285
return self.query_region_async(coordinates, radius=radius, pagesize=pagesize, page=page)
284286

@@ -318,7 +320,7 @@ def query_criteria_async(self, *, pagesize=None, page=None, resolver=None, **cri
318320
response : list of `~requests.Response`
319321
"""
320322

321-
position, mashup_filters = self._parse_caom_criteria(resolver, **criteria)
323+
position, mashup_filters = self._parse_caom_criteria(resolver=resolver, **criteria)
322324

323325
if not mashup_filters:
324326
raise InvalidQueryError("At least one non-positional criterion must be supplied.")
@@ -405,7 +407,7 @@ def query_object_count(self, objectname, *, radius=0.2*u.deg, pagesize=None, pag
405407
response : int
406408
"""
407409

408-
coordinates = utils.resolve_object(objectname, resolver)
410+
coordinates = utils.resolve_object(objectname, resolver=resolver)
409411

410412
return self.query_region_count(coordinates, radius=radius, pagesize=pagesize, page=page)
411413

@@ -443,7 +445,7 @@ def query_criteria_count(self, *, pagesize=None, page=None, resolver=None, **cri
443445
response : int
444446
"""
445447

446-
position, mashup_filters = self._parse_caom_criteria(resolver, **criteria)
448+
position, mashup_filters = self._parse_caom_criteria(resolver=resolver, **criteria)
447449

448450
# send query
449451
if position:

astroquery/mast/utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,14 @@ def _simple_request(url, params=None):
8787
return response
8888

8989

90-
def resolve_object(objectname, resolver=None, resolve_all=False):
90+
def resolve_object(objectname, *, resolver=None, resolve_all=False):
9191
"""
9292
Resolves an object name to a position on the sky.
9393
9494
Parameters
9595
----------
9696
objectname : str
9797
Name of astronomical object to resolve.
98-
resolver : str, List, optional
99-
Name of resolver. Must be "NED" or "SIMBAD". This parameter is case-insensitive.
10098
resolver : str, optional
10199
The resolver to use when resolving a named target into coordinates. Valid options are "SIMBAD" and "NED".
102100
If not specified, the default resolver order will be used. Please see the
@@ -195,7 +193,7 @@ def resolve_object(objectname, resolver=None, resolve_all=False):
195193
return coord
196194

197195

198-
def parse_input_location(coordinates=None, objectname=None, resolver=None):
196+
def parse_input_location(*, coordinates=None, objectname=None, resolver=None):
199197
"""
200198
Convenience function to parse user input of coordinates and objectname.
201199
@@ -232,7 +230,7 @@ def parse_input_location(coordinates=None, objectname=None, resolver=None):
232230
warnings.warn("Resolver is only used when resolving object names and will be ignored.", InputWarning)
233231

234232
if objectname:
235-
obj_coord = resolve_object(objectname, resolver)
233+
obj_coord = resolve_object(objectname, resolver=resolver)
236234

237235
if coordinates:
238236
obj_coord = commons.parse_coordinates(coordinates)

0 commit comments

Comments
 (0)