Skip to content

Commit a314e9a

Browse files
committed
Formatting fixes
1 parent d736003 commit a314e9a

File tree

3 files changed

+24
-29
lines changed

3 files changed

+24
-29
lines changed

astroquery/casda/core.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -124,36 +124,36 @@ def _args_to_payload(self, **kwargs):
124124
if kwargs.get('band') is not None:
125125
if kwargs.get('channel') is not None:
126126
raise ValueError("Either 'channel' or 'band' values may be provided but not both.")
127-
127+
128128
band = kwargs.get('band')
129-
if not isinstance(band, (list,tuple)) or len(band) != 2:
129+
if not isinstance(band, (list, tuple)) or len(band) != 2:
130130
raise ValueError("The 'band' value must be a list of 2 wavelength or frequency values.")
131131
if (band[0] is not None and not isinstance(band[0], u.Quantity)) or (band[1] is not None and not isinstance(band[1], u.Quantity)):
132132
raise ValueError("The 'band' value must be a list of 2 wavelength or frequency values.")
133133
if band[0] is not None and band[1] is not None and band[0].unit.physical_type != band[1].unit.physical_type:
134134
raise ValueError("The 'band' values must have the same kind of units.")
135135
if band[0] is not None or band[1] is not None:
136136
unit = band[0].unit if band[0] is not None else band[1].unit
137-
if unit.physical_type == 'length':
137+
if unit.physical_type == 'length':
138138
min_band = '-Inf' if band[0] is None else str(band[0].to(u.m).value)
139139
max_band = '+Inf' if band[1] is None else str(band[1].to(u.m).value)
140-
elif unit.physical_type == 'frequency':
140+
elif unit.physical_type == 'frequency':
141141
# Swap the order when changing frequency to wavelength
142142
min_band = '-Inf' if band[1] is None else str(band[1].to(u.m, equivalencies=u.spectral()).value)
143143
max_band = '+Inf' if band[0] is None else str(band[0].to(u.m, equivalencies=u.spectral()).value)
144144
else:
145145
raise ValueError("The 'band' values must be wavelengths or frequencies.")
146-
146+
147147
request_payload['BAND'] = '{} {}'.format(min_band, max_band)
148148

149149
if kwargs.get('channel') is not None:
150150
channel = kwargs.get('channel')
151-
if not isinstance(channel, (list,tuple)) or len(channel) != 2:
151+
if not isinstance(channel, (list, tuple)) or len(channel) != 2:
152152
raise ValueError("The 'channel' value must be a list of 2 integer values.")
153153
if (not isinstance(channel[0], int)) or (not isinstance(channel[1], int)):
154154
raise ValueError("The 'channel' value must be a list of 2 integer values.")
155155
request_payload['CHANNEL'] = '{} {}'.format(channel[0], channel[1])
156-
156+
157157
return request_payload
158158

159159
# the methods above implicitly call the private _parse_result method.
@@ -194,7 +194,6 @@ def filter_out_unreleased(self, table):
194194
now = str(datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%S.%f'))
195195
return table[(table['obs_release_date'] != '') & (table['obs_release_date'] < now)]
196196

197-
198197
def _create_job(self, table, service_name, verbose):
199198
# Use datalink to get authenticated access for each file
200199
tokens = []
@@ -218,7 +217,7 @@ def _create_job(self, table, service_name, verbose):
218217
job_url = self._create_soda_job(tokens, soda_url=soda_url)
219218
if verbose:
220219
log.info("Created data staging job " + job_url)
221-
220+
222221
return job_url
223222

224223
def _complete_job(self, job_url, verbose):
@@ -262,19 +261,18 @@ def stage_data(self, table, verbose=False):
262261
return []
263262

264263
job_url = self._create_job(table, 'async_service', verbose)
265-
266-
return self._complete_job(job_url, verbose)
267264

265+
return self._complete_job(job_url, verbose)
268266

269267
def cutout(self, table, coordinates=None, radius=None, height=None, width=None, band=None, channel=None, verbose=False):
270268
"""
271-
Produce a cutout from each selected file. All requests for data must use authentication. If you have access to
272-
the data, the requested files will be brought online, a cutout produced from each file and a set of URLs to
269+
Produce a cutout from each selected file. All requests for data must use authentication. If you have access to
270+
the data, the requested files will be brought online, a cutout produced from each file and a set of URLs to
273271
download the cutouts will be returned.
274272
275-
If a set of coordinates is provided along with either a radius or a box height and width, then CASDA will produce a
276-
spatial cutout at that location from each data file specified in the table. If a band or channel pair is provided
277-
then CASDA will produce a spectral cutout of that range from each data file. These can be combined to produce
273+
If a set of coordinates is provided along with either a radius or a box height and width, then CASDA will produce a
274+
spatial cutout at that location from each data file specified in the table. If a band or channel pair is provided
275+
then CASDA will produce a spectral cutout of that range from each data file. These can be combined to produce
278276
subcubes with restrictions in both spectral and spatial axes.
279277
280278
Parameters
@@ -422,10 +420,9 @@ def _create_soda_job(self, authenticated_id_tokens, soda_url=None):
422420
resp.raise_for_status()
423421
return resp.url
424422

425-
426423
def _add_cutout_params(self, job_location, verbose, cutout_spec):
427424
"""
428-
Add a cutout specification to an async SODA job. This will change the job
425+
Add a cutout specification to an async SODA job. This will change the job
429426
from just retrieving the full file to producing a cutout from the target file.
430427
431428
Parameters
@@ -437,7 +434,6 @@ def _add_cutout_params(self, job_location, verbose, cutout_spec):
437434
cutout_spec: map
438435
The map containing the POS parameter defining the cutout.
439436
"""
440-
#params = list(map((lambda value: (param_key, value)), cutout_spec))
441437
if verbose:
442438
log.info("Adding parameters: " + str(cutout_spec))
443439
resp = self._request('POST', job_location + '/parameters', data=cutout_spec, cache=False)

astroquery/casda/tests/test_casda.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def get_mockreturn(self, method, url, data=None, timeout=10,
5757
print(data['POS'])
5858
pos_parts = data['POS'].split(' ')
5959
assert len(pos_parts) == 4
60-
self.completed_job_key = 'cutout_{}_{:.4f}_{:.4f}_{:.4f}'.format(pos_parts[0], float(pos_parts[1]),
60+
self.completed_job_key = 'cutout_{}_{:.4f}_{:.4f}_{:.4f}'.format(pos_parts[0], float(pos_parts[1]),
6161
float(pos_parts[2]), float(pos_parts[3]))
6262
return create_soda_create_response('111-000-111-000')
6363
elif str(url).endswith('111-000-111-000') and method == 'GET':
@@ -323,19 +323,19 @@ def test_cutout_no_args(patch_get):
323323

324324
def test_args_to_payload_band():
325325
casda = Casda('user', 'password')
326-
payload = casda._args_to_payload(band=(0.195*u.m,0.215*u.m))
326+
payload = casda._args_to_payload(band=(0.195*u.m, 0.215*u.m))
327327
assert payload['BAND'] == '0.195 0.215'
328328
assert list(payload.keys()) == ['BAND']
329329

330-
payload = casda._args_to_payload(band=(0.195*u.m,21.5*u.cm))
330+
payload = casda._args_to_payload(band=(0.195*u.m, 21.5*u.cm))
331331
assert payload['BAND'] == '0.195 0.215'
332332
assert list(payload.keys()) == ['BAND']
333333

334-
payload = casda._args_to_payload(band=(None,0.215*u.m))
334+
payload = casda._args_to_payload(band=(None, 0.215*u.m))
335335
assert payload['BAND'] == '-Inf 0.215'
336336
assert list(payload.keys()) == ['BAND']
337337

338-
payload = casda._args_to_payload(band=(0.195*u.m,None))
338+
payload = casda._args_to_payload(band=(0.195*u.m, None))
339339
assert payload['BAND'] == '0.195 +Inf'
340340
assert list(payload.keys()) == ['BAND']
341341

@@ -360,7 +360,7 @@ def test_args_to_payload_band_invalid():
360360
assert "The 'band' value must be a list of 2 wavelength or frequency values." in str(excinfo.value)
361361

362362
with pytest.raises(ValueError) as excinfo:
363-
casda._args_to_payload(band=(0.195*u.m,0.215*u.m,0.3*u.m))
363+
casda._args_to_payload(band=(0.195*u.m, 0.215*u.m, 0.3*u.m))
364364
assert "The 'band' value must be a list of 2 wavelength or frequency values." in str(excinfo.value)
365365

366366
with pytest.raises(ValueError) as excinfo:
@@ -376,7 +376,7 @@ def test_args_to_payload_band_invalid():
376376
assert "The 'band' values must be wavelengths or frequencies." in str(excinfo.value)
377377

378378
with pytest.raises(ValueError) as excinfo:
379-
casda._args_to_payload(band=(1.42*u.GHz, 1.5*u.GHz), channel=(5,10))
379+
casda._args_to_payload(band=(1.42*u.GHz, 1.5*u.GHz), channel=(5, 10))
380380
assert "Either 'channel' or 'band' values may be provided but not both." in str(excinfo.value)
381381

382382

astroquery/casda/tests/test_casda_remote.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from astropy.table import Table, Column
1010
import astropy.units as u
11-
from astropy.coordinates import SkyCoord
11+
from astropy.coordinates import SkyCoord
1212

1313
from astroquery.casda import Casda
1414

@@ -63,7 +63,6 @@ def test_cutout(self):
6363
prefix = 'https://data.csiro.au/casda_vo_proxy/vo/datalink/links?ID='
6464
access_urls = [prefix + 'cube-44705']
6565
table = Table([Column(data=access_urls, name='access_url')])
66-
print (os.environ.keys)
6766
casda = Casda(os.environ['CASDA_USER'], os.environ['CASDA_PASSWD'])
6867
casda.POLL_INTERVAL = 3
6968
pos = SkyCoord(196.49583333*u.deg, -62.7*u.deg)
@@ -75,7 +74,7 @@ def test_cutout(self):
7574
checksum_url = str(url)
7675
else:
7776
cutout_url = str(url)
78-
77+
7978
assert cutout_url.endswith('-imagecube-44705.fits')
8079
assert 'cutout-' in cutout_url
8180
assert checksum_url.endswith('-imagecube-44705.fits.checksum')

0 commit comments

Comments
 (0)