@@ -56,7 +56,7 @@ class SDSSClass(BaseQuery):
56
56
'qso_bal' : [30 , 31 ], 'qso_bright' : 32
57
57
}
58
58
59
- def query_crossid_async (self , coordinates , radius = 5. * u .arcsec , timeout = TIMEOUT ,
59
+ def query_crossid_async (self , coordinates , * , radius = 5. * u .arcsec , timeout = TIMEOUT ,
60
60
fields = None , photoobj_fields = None , specobj_fields = None , obj_names = None ,
61
61
spectro = False , region = False , field_help = False , get_query_payload = False ,
62
62
data_release = conf .default_release , cache = True ):
@@ -131,10 +131,10 @@ def query_crossid_async(self, coordinates, radius=5. * u.arcsec, timeout=TIMEOUT
131
131
"""
132
132
133
133
if isinstance (radius , Angle ):
134
- radius = radius .to (u .arcmin ). value
134
+ radius = radius .to_value (u .arcmin )
135
135
else :
136
136
try :
137
- radius = Angle (radius ).to (u .arcmin ). value
137
+ radius = Angle (radius ).to_value (u .arcmin )
138
138
except ValueError :
139
139
raise TypeError ("radius should be either Quantity or "
140
140
"convertible to float." )
@@ -147,7 +147,7 @@ def query_crossid_async(self, coordinates, radius=5. * u.arcsec, timeout=TIMEOUT
147
147
not coordinates .isscalar )):
148
148
coordinates = [coordinates ]
149
149
if obj_names is None :
150
- obj_names = ['obj_{0}' . format ( i ) for i in range (len (coordinates ))]
150
+ obj_names = [f 'obj_{ i :d } ' for i in range (len (coordinates ))]
151
151
elif len (obj_names ) != len (coordinates ):
152
152
raise ValueError ("Number of coordinates and obj_names should "
153
153
"be equal" )
@@ -193,7 +193,7 @@ def query_crossid_async(self, coordinates, radius=5. * u.arcsec, timeout=TIMEOUT
193
193
timeout = timeout , cache = cache )
194
194
return response
195
195
196
- def query_region_async (self , coordinates , radius = 2. * u .arcsec , timeout = TIMEOUT ,
196
+ def query_region_async (self , coordinates , * , radius = 2. * u .arcsec , timeout = TIMEOUT ,
197
197
fields = None , photoobj_fields = None , specobj_fields = None , obj_names = None ,
198
198
spectro = False , field_help = False , get_query_payload = False ,
199
199
data_release = conf .default_release , cache = True ):
@@ -297,7 +297,7 @@ def query_region_async(self, coordinates, radius=2. * u.arcsec, timeout=TIMEOUT,
297
297
timeout = timeout , cache = cache )
298
298
return response
299
299
300
- def query_specobj_async (self , plate = None , mjd = None , fiberID = None ,
300
+ def query_specobj_async (self , * , plate = None , mjd = None , fiberID = None ,
301
301
fields = None , timeout = TIMEOUT ,
302
302
get_query_payload = False , field_help = False ,
303
303
data_release = conf .default_release , cache = True ):
@@ -373,7 +373,7 @@ def query_specobj_async(self, plate=None, mjd=None, fiberID=None,
373
373
timeout = timeout , cache = cache )
374
374
return response
375
375
376
- def query_photoobj_async (self , run = None , rerun = 301 , camcol = None ,
376
+ def query_photoobj_async (self , * , run = None , rerun = 301 , camcol = None ,
377
377
field = None , fields = None , timeout = TIMEOUT ,
378
378
get_query_payload = False , field_help = False ,
379
379
data_release = conf .default_release , cache = True ):
@@ -459,7 +459,7 @@ def __sanitize_query(self, stmt):
459
459
fsql += ' ' + line .split ('--' )[0 ]
460
460
return fsql
461
461
462
- def query_sql_async (self , sql_query , timeout = TIMEOUT ,
462
+ def query_sql_async (self , sql_query , * , timeout = TIMEOUT ,
463
463
data_release = conf .default_release ,
464
464
cache = True , ** kwargs ):
465
465
"""
@@ -809,7 +809,7 @@ def get_images(self, coordinates=None, radius=2. * u.arcsec,
809
809
else :
810
810
return [obj .get_fits () for obj in readable_objs ]
811
811
812
- def get_spectral_template_async (self , kind = 'qso' , timeout = TIMEOUT ,
812
+ def get_spectral_template_async (self , kind = 'qso' , * , timeout = TIMEOUT ,
813
813
show_progress = True ):
814
814
"""
815
815
Download spectral templates from SDSS DR-2.
@@ -864,7 +864,7 @@ def get_spectral_template_async(self, kind='qso', timeout=TIMEOUT,
864
864
return results
865
865
866
866
@prepend_docstr_nosections (get_spectral_template_async .__doc__ )
867
- def get_spectral_template (self , kind = 'qso' , timeout = TIMEOUT ,
867
+ def get_spectral_template (self , kind = 'qso' , * , timeout = TIMEOUT ,
868
868
show_progress = True ):
869
869
"""
870
870
Returns
@@ -888,6 +888,8 @@ def _parse_result(self, response, verbose=False):
888
888
----------
889
889
response : `requests.Response`
890
890
Result of requests -> np.atleast_1d.
891
+ verbose : bool, optional
892
+ Not currently used.
891
893
892
894
Returns
893
895
-------
@@ -990,18 +992,18 @@ def _args_to_payload(self, coordinates=None,
990
992
elif field_help :
991
993
ret = 0
992
994
if field_help in photoobj_all :
993
- print ("{0 } is a valid 'photoobj_field'". format ( field_help ) )
995
+ print (f" { field_help } is a valid 'photoobj_field'" )
994
996
ret += 1
995
997
if field_help in specobj_all :
996
- print ("{0 } is a valid 'specobj_field'". format ( field_help ) )
998
+ print (f" { field_help } is a valid 'specobj_field'" )
997
999
ret += 1
998
1000
if ret > 0 :
999
1001
return
1000
1002
else :
1001
1003
if field_help is not True :
1002
- warnings .warn ("{0 } isn't a valid 'photobj_field' or "
1004
+ warnings .warn (f" { field_help } isn't a valid 'photobj_field' or "
1003
1005
"'specobj_field' field, valid fields are"
1004
- "returned." . format ( field_help ) )
1006
+ "returned." )
1005
1007
return {'photoobj_all' : photoobj_all ,
1006
1008
'specobj_all' : specobj_all }
1007
1009
@@ -1025,18 +1027,18 @@ def _args_to_payload(self, coordinates=None,
1025
1027
for sql_field in fields :
1026
1028
if (sql_field in photoobj_all
1027
1029
or sql_field .lower () in photoobj_all ):
1028
- q_select_field .append ('p.{0}' . format ( sql_field ) )
1030
+ q_select_field .append (f 'p.{ sql_field } ' )
1029
1031
elif (sql_field in specobj_all
1030
1032
or sql_field .lower () in specobj_all ):
1031
1033
fields_spectro = True
1032
- q_select_field .append ('s.{0}' . format ( sql_field ) )
1034
+ q_select_field .append (f 's.{ sql_field } ' )
1033
1035
1034
1036
if photoobj_fields is not None :
1035
1037
for sql_field in photoobj_fields :
1036
- q_select_field .append ('p.{0}' . format ( sql_field ) )
1038
+ q_select_field .append (f 'p.{ sql_field } ' )
1037
1039
if specobj_fields is not None :
1038
1040
for sql_field in specobj_fields :
1039
- q_select_field .append ('s.{0}' . format ( sql_field ) )
1041
+ q_select_field .append (f 's.{ sql_field } ' )
1040
1042
if crossid and fields is None :
1041
1043
q_select_field .append ('s.SpecObjID AS obj_id' )
1042
1044
if crossid :
@@ -1076,7 +1078,7 @@ def _args_to_payload(self, coordinates=None,
1076
1078
raise ValueError ('must specify at least one of `coordinates`, '
1077
1079
'`run`, `camcol` or `field`' )
1078
1080
1079
- sql = "{0 } {1 } {2}" . format ( q_select , q_from , q_where )
1081
+ sql = f" { q_select } { q_from } { q_where } "
1080
1082
1081
1083
# In DR 8 & DR9 the format parameter is case-sensitive, but in later
1082
1084
# releases that does not appear to be the case. In principle 'csv'
@@ -1094,6 +1096,8 @@ def _args_to_payload(self, coordinates=None,
1094
1096
return request_payload
1095
1097
1096
1098
def _get_query_url (self , data_release ):
1099
+ """Generate URL for generic SQL queries.
1100
+ """
1097
1101
if data_release < 10 :
1098
1102
suffix = self .QUERY_URL_SUFFIX_DR_OLD
1099
1103
elif data_release == 10 :
@@ -1106,6 +1110,8 @@ def _get_query_url(self, data_release):
1106
1110
return url
1107
1111
1108
1112
def _get_crossid_url (self , data_release ):
1113
+ """Generate URL for CrossID queries.
1114
+ """
1109
1115
if data_release < 10 :
1110
1116
suffix = self .XID_URL_SUFFIX_OLD
1111
1117
elif data_release == 10 :
0 commit comments