Skip to content

Commit 30f774f

Browse files
committed
MAINT: autopep8 fixes
1 parent 25277fa commit 30f774f

File tree

84 files changed

+654
-607
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+654
-607
lines changed

astroquery/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def _get_bibtex():
2727

2828
with open(citation_file, 'r') as citation:
2929
refs = citation.read().split('@ARTICLE')[1:]
30-
if len(refs) == 0: return ''
30+
if len(refs) == 0:
31+
return ''
3132
bibtexreference = "@ARTICLE{0}".format(refs[0])
3233
return bibtexreference
3334

astroquery/alma/core.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,6 @@ def _get_dataarchive_url(self):
533533

534534
def get_data_info(self, uids, *, expand_tarfiles=False,
535535
with_auxiliary=True, with_rawdata=True):
536-
537536
"""
538537
Return information about the data associated with ALMA uid(s)
539538
@@ -729,7 +728,7 @@ def download_files(self, files, *, savedir=None, cache=True,
729728
" next file".format(url=file_link))
730729
continue
731730
else:
732-
raise(ex)
731+
raise (ex)
733732

734733
try:
735734
filename = re.search("filename=(.*)",
@@ -781,7 +780,7 @@ def download_files(self, files, *, savedir=None, cache=True,
781780
" next file".format(url=file_link))
782781
continue
783782
else:
784-
raise(ex)
783+
raise (ex)
785784
elif ex.response.status_code == 403:
786785
log.error("Access denied to {url}".format(url=file_link))
787786
if 'dataPortal' in file_link and 'sso' not in file_link:

astroquery/alma/tests/test_alma.py

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ def test_gen_array_sql():
180180
common_select = "select * from ivoa.obscore WHERE "
181181
test_keywords = ["High-mass star formation", "Disks around high-mass stars"]
182182
assert _gen_sql({"spatial_resolution": "<0.1",
183-
"science_keyword": test_keywords}) == common_select + \
184-
"spatial_resolution<=0.1 AND (science_keyword='High-mass star formation' OR science_keyword='Disks around high-mass stars')"
183+
"science_keyword": test_keywords}) == common_select + \
184+
"spatial_resolution<=0.1 AND (science_keyword='High-mass star formation' OR science_keyword='Disks around high-mass stars')"
185185

186186

187187
def test_gen_datetime_sql():
@@ -403,9 +403,9 @@ def test_tap():
403403

404404
@pytest.mark.parametrize('data_archive_url',
405405
[
406-
('https://almascience.nrao.edu'),
407-
('https://almascience.eso.org'),
408-
('https://almascience.nao.ac.jp')
406+
('https://almascience.nrao.edu'),
407+
('https://almascience.eso.org'),
408+
('https://almascience.nao.ac.jp')
409409
])
410410
def test_tap_url(data_archive_url):
411411
_test_tap_url(data_archive_url)
@@ -420,9 +420,9 @@ def _test_tap_url(data_archive_url):
420420

421421
@pytest.mark.parametrize('data_archive_url',
422422
[
423-
('https://almascience.nrao.edu'),
424-
('https://almascience.eso.org'),
425-
('https://almascience.nao.ac.jp')
423+
('https://almascience.nrao.edu'),
424+
('https://almascience.eso.org'),
425+
('https://almascience.nao.ac.jp')
426426
])
427427
def test_sia_url(data_archive_url):
428428
_test_sia_url(data_archive_url)
@@ -437,9 +437,9 @@ def _test_sia_url(data_archive_url):
437437

438438
@pytest.mark.parametrize('data_archive_url',
439439
[
440-
('https://almascience.nrao.edu'),
441-
('https://almascience.eso.org'),
442-
('https://almascience.nao.ac.jp')
440+
('https://almascience.nrao.edu'),
441+
('https://almascience.eso.org'),
442+
('https://almascience.nao.ac.jp')
443443
])
444444
def test_datalink_url(data_archive_url):
445445
_test_datalink_url(data_archive_url)
@@ -467,13 +467,25 @@ def run_sync(self, uid):
467467
# This method will be used by the mock in test_get_data_info_expand_tarfiles to replace requests.get
468468
def _mocked_datalink_sync(*args, **kwargs):
469469
class MockResponse:
470-
adhoc_service_1_param1 = type('', (object, ), {'ID': 'standardID', 'value': 'ivo://ivoa.net/std/DataLink#links-1.0'})()
471-
adhoc_service_1_param2 = type('', (object, ), {'ID': 'accessURL', 'value': 'https://almascience.org/datalink/sync?ID=2017.1.01185.S_uid___A001_X12a3_Xe9_001_of_001.tar'})()
472-
adhoc_service_1 = type('', (object, ), {'ID': 'DataLink.2017.1.01185.S_uid___A001_X12a3_Xe9_001_of_001.tar', 'params': [adhoc_service_1_param1, adhoc_service_1_param2]})()
473-
474-
adhoc_service_2_param1 = type('', (object, ), {'ID': 'standardID', 'value': 'ivo://ivoa.net/std/DataLink#links-1.0'})()
475-
adhoc_service_2_param2 = type('', (object, ), {'ID': 'accessURL', 'value': 'https://almascience.org/datalink/sync?ID=2017.1.01185.S_uid___A001_X12a3_Xe9_auxiliary.tar'})()
476-
adhoc_service_2 = type('', (object, ), {'ID': 'DataLink.2017.1.01185.S_uid___A001_X12a3_Xe9_auxiliary.tar', 'params': [adhoc_service_1_param1, adhoc_service_1_param2]})()
470+
adhoc_service_1_param1 = type('', (object, ), {'ID': 'standardID',
471+
'value': 'ivo://ivoa.net/std/DataLink#links-1.0'})()
472+
adhoc_service_1_param2 = type(
473+
'', (object, ), {
474+
'ID': 'accessURL', 'value': 'https://almascience.org/datalink/sync?ID=2017.1.01185.S_uid___A001_X12a3_Xe9_001_of_001.tar'})()
475+
adhoc_service_1 = type(
476+
'', (object, ), {
477+
'ID': 'DataLink.2017.1.01185.S_uid___A001_X12a3_Xe9_001_of_001.tar', 'params': [
478+
adhoc_service_1_param1, adhoc_service_1_param2]})()
479+
480+
adhoc_service_2_param1 = type('', (object, ), {'ID': 'standardID',
481+
'value': 'ivo://ivoa.net/std/DataLink#links-1.0'})()
482+
adhoc_service_2_param2 = type(
483+
'', (object, ), {
484+
'ID': 'accessURL', 'value': 'https://almascience.org/datalink/sync?ID=2017.1.01185.S_uid___A001_X12a3_Xe9_auxiliary.tar'})()
485+
adhoc_service_2 = type(
486+
'', (object, ), {
487+
'ID': 'DataLink.2017.1.01185.S_uid___A001_X12a3_Xe9_auxiliary.tar', 'params': [
488+
adhoc_service_1_param1, adhoc_service_1_param2]})()
477489

478490
adhoc_services = {
479491
'DataLink.2017.1.01185.S_uid___A001_X12a3_Xe9_001_of_001.tar': adhoc_service_1,

astroquery/alma/tests/test_alma_remote.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,8 @@ def test_big_download_regression(alma):
548548
@pytest.mark.remote_data
549549
def test_download_html_file(alma, tmp_path):
550550
alma.cache_location = tmp_path
551-
result = alma.download_files(['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)])
551+
result = alma.download_files(
552+
['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)])
552553
assert result
553554

554555

@@ -557,10 +558,12 @@ def test_verify_html_file(alma, caplog, tmp_path):
557558
alma.cache_location = tmp_path
558559

559560
# download the file
560-
result = alma.download_files(['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)])
561+
result = alma.download_files(
562+
['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)])
561563
assert 'member.uid___A001_X1284_X1353.qa2_report.html' in result[0]
562564

563-
result = alma.download_files(['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)], verify_only=True)
565+
result = alma.download_files(
566+
['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)], verify_only=True)
564567
assert 'member.uid___A001_X1284_X1353.qa2_report.html' in result[0]
565568
local_filepath = Path(result[0])
566569
expected_file_length = local_filepath.stat().st_size
@@ -574,15 +577,17 @@ def test_verify_html_file(alma, caplog, tmp_path):
574577
new_file_length = expected_file_length + 10
575578
with pytest.warns(expected_warning=CorruptDataWarning,
576579
match=f"Found cached file {local_filepath} with size {new_file_length} > expected size {expected_file_length}. The download is likely corrupted."):
577-
result = alma.download_files(['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)], verify_only=True)
580+
result = alma.download_files(
581+
['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)], verify_only=True)
578582
assert 'member.uid___A001_X1284_X1353.qa2_report.html' in result[0]
579583

580584
# manipulate the file: make it small
581585
with open(local_filepath, 'wb') as fh:
582586
fh.write(b"Empty Text")
583587

584588
caplog.clear()
585-
result = alma.download_files(['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)], verify_only=True)
589+
result = alma.download_files(
590+
['https://{}/dataPortal/member.uid___A001_X1284_X1353.qa2_report.html'.format(download_hostname)], verify_only=True)
586591
assert 'member.uid___A001_X1284_X1353.qa2_report.html' in result[0]
587592
existing_file_length = 10
588593
assert f"Found cached file {local_filepath} with size {existing_file_length} < expected size {expected_file_length}. The download should be continued." in caplog.text

astroquery/alma/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def parse_frequency_support(frequency_support_str):
3030

3131
freq_ranges = [(float(sup[0]),
3232
float(sup[1].split(',')[0].strip(string.ascii_letters))) *
33-
u.Unit(sup[1].split(',')[0].strip(string.punctuation +
34-
string.digits))
33+
u.Unit(sup[1].split(',')[0].strip(string.punctuation
34+
+ string.digits))
3535
for i in supports for sup in [i.strip('[] ').split('..'), ]]
3636
return u.Quantity(freq_ranges)
3737

@@ -95,7 +95,7 @@ def approximate_primary_beam_sizes(frequency_support_str,
9595
as :math:`R = 1.22 \lambda/D`
9696
"""
9797
freq_ranges = parse_frequency_support(frequency_support_str)
98-
beam_sizes = [(first_null * fr.mean().to(u.m, u.spectral()) /
99-
(dish_diameter)).to(u.arcsec, u.dimensionless_angles())
98+
beam_sizes = [(first_null * fr.mean().to(u.m, u.spectral())
99+
/ (dish_diameter)).to(u.arcsec, u.dimensionless_angles())
100100
for fr in freq_ranges]
101101
return u.Quantity(beam_sizes)

astroquery/atomic/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ def _get_default_form_values(self, form):
327327
continue
328328
# check boxes: enabled boxes have the value "on" if not specified
329329
# otherwise. Found out by debugging, perhaps not documented.
330-
if (elem.get('type') == 'checkbox' and
331-
elem.get('checked') in ["", "checked"]):
330+
if (elem.get('type') == 'checkbox'
331+
and elem.get('checked') in ["", "checked"]):
332332
value = elem.get('value', 'on')
333333
# radio buttons and simple input fields
334334
if elem.get('type') == 'radio' and\

astroquery/atomic/tests/test_atomic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ def test_transitions():
5959
assert isinstance(Transition.M1, MultiTransition)
6060
assert len(Transition.IC | Transition.M1) == 2
6161
# associativity
62-
assert ((Transition.IC | Transition.M1) | Transition.E1 ==
63-
Transition.IC | (Transition.M1 | Transition.E1))
62+
assert ((Transition.IC | Transition.M1) | Transition.E1
63+
== Transition.IC | (Transition.M1 | Transition.E1))
6464
# commutativity
6565
assert Transition.IC | Transition.M1 == Transition.M1 | Transition.IC
6666
assert str((Transition.IC | Transition.M1)) == 'IC,M1'

astroquery/atomic/tests/test_atomic_remote.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ def test_query_with_wavelength_params():
5252
cache=False)
5353
assert isinstance(result, Table)
5454
assert result.colnames == ['LAMBDA VAC ANG', 'SPECTRUM', 'TT',
55-
'CONFIGURATION', 'TERM', 'J J', 'A_ki',
56-
'LEVEL ENERGY CM 1']
57-
assert np.all(result['LAMBDA VAC ANG'] ==
58-
np.array([196.8874, 197.7992, 199.0122]))
55+
'CONFIGURATION', 'TERM', 'J J', 'A_ki',
56+
'LEVEL ENERGY CM 1']
57+
assert np.all(result['LAMBDA VAC ANG']
58+
== np.array([196.8874, 197.7992, 199.0122]))
5959
assert np.all(result['SPECTRUM'] == np.array(['C IV', 'C IV', 'C IV']))
6060
assert np.all(result['TT'] == np.array(['E1', 'E1', 'E1']))
6161
assert np.all(result['TERM'] == np.array(['2S-2Po', '2S-2Po', '2S-2Po']))
6262
assert np.all(result['J J'] == np.array(['1/2-*', '1/2-*', '1/2-*']))
63-
assert np.all(result['LEVEL ENERGY CM 1'] ==
64-
np.array(['0.00 - 507904.40', '0.00 - 505563.30',
65-
'0.00 - 502481.80']))
63+
assert np.all(result['LEVEL ENERGY CM 1']
64+
== np.array(['0.00 - 507904.40', '0.00 - 505563.30',
65+
'0.00 - 502481.80']))
6666

6767

6868
def test_empty_result_set():
@@ -79,5 +79,5 @@ def test_lower_upper_ranges():
7979
element_spectrum='Ne III', cache=False)
8080
assert isinstance(result, Table)
8181

82-
assert np.all(result['LAMBDA VAC ANG'] ==
83-
np.array([1814.73, 3968.91, 4013.14]))
82+
assert np.all(result['LAMBDA VAC ANG']
83+
== np.array([1814.73, 3968.91, 4013.14]))

astroquery/atomic/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ def is_valid_transitions_param(transitions):
1111
is_custom_choice = isinstance(transitions, MultiTransition) and\
1212
all(t not in simple_transitions for t in transitions)
1313

14-
return (transitions is None or transitions in simple_transitions or
15-
is_custom_choice)
14+
return (transitions is None or transitions in simple_transitions
15+
or is_custom_choice)

astroquery/besancon/core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ def _parse_args(self, glon, glat, email, smallfield=True, extinction=0.7,
223223
"""
224224
if email is None and hasattr(self, 'email'):
225225
email = self.email
226-
if (email is None or not isinstance(email, str) or
227-
not commons.validate_email(email)):
226+
if (email is None or not isinstance(email, str)
227+
or not commons.validate_email(email)):
228228
raise ValueError("Must specify a valid e-mail address.")
229229

230230
# create a new keyword dict based on inputs + defaults
@@ -274,8 +274,8 @@ def _parse_args(self, glon, glat, email, smallfield=True, extinction=0.7,
274274
# convert all array elements to arrays
275275
for dummy in range(2): # deal with nested lists
276276
for k, v in list(request_data.items()):
277-
if (isinstance(v, list) or
278-
(isinstance(v, tuple) and len(v) > 1)):
277+
if (isinstance(v, list)
278+
or (isinstance(v, tuple) and len(v) > 1)):
279279
if k in request_data:
280280
del request_data[k]
281281
for index, val in enumerate(v):

0 commit comments

Comments
 (0)