Skip to content

Commit bdf251a

Browse files
committed
MAINT: removing workarounds for astropy 4.0
1 parent 3a6587b commit bdf251a

File tree

14 files changed

+57
-139
lines changed

14 files changed

+57
-139
lines changed

astroquery/alma/core.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -579,11 +579,7 @@ def get_data_info(self, uids, *, expand_tarfiles=False,
579579
datalink_service_def_dict[adhoc_service.ID] = adhoc_service
580580

581581
temp = res.to_table()
582-
if commons.ASTROPY_LT_4_1:
583-
# very annoying
584-
for col in [x for x in temp.colnames
585-
if x not in ['content_length', 'readable']]:
586-
temp[col] = temp[col].astype(str)
582+
587583
result = temp if result is None else vstack([result, temp])
588584
to_delete = []
589585
for index, rr in enumerate(result):
@@ -1214,10 +1210,8 @@ def get_project_metadata(self, projectid, *, cache=True):
12141210
result = self.query_tap(
12151211
"select distinct proposal_abstract from "
12161212
"ivoa.obscore where proposal_id='{}'".format(projectid))
1217-
if commons.ASTROPY_LT_4_1:
1218-
return [result[0]['proposal_abstract'].astype(str)]
1219-
else:
1220-
return [result[0]['proposal_abstract']]
1213+
1214+
return [result[0]['proposal_abstract']]
12211215

12221216

12231217
Alma = AlmaClass()

astroquery/alma/tests/test_alma_remote.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
pass
1818

1919
from astroquery.exceptions import CorruptDataWarning
20-
from astroquery.utils.commons import ASTROPY_LT_4_1
2120
from .. import Alma
2221

2322
# ALMA tests involving staging take too long, leading to travis timeouts
@@ -283,14 +282,10 @@ def test_doc_example(self, tmp_path, alma):
283282
content_length_column_name = 'content_length'
284283

285284
uids = np.unique(m83_data['Member ous id'])
286-
if ASTROPY_LT_4_1:
287-
assert b'uid://A001/X11f/X30' in uids
288-
X30 = (m83_data['Member ous id'] == b'uid://A001/X11f/X30')
289-
X31 = (m83_data['Member ous id'] == b'uid://A002/X3216af/X31')
290-
else:
291-
assert 'uid://A001/X11f/X30' in uids
292-
X30 = (m83_data['Member ous id'] == 'uid://A001/X11f/X30')
293-
X31 = (m83_data['Member ous id'] == 'uid://A002/X3216af/X31')
285+
286+
assert 'uid://A001/X11f/X30' in uids
287+
X30 = (m83_data['Member ous id'] == 'uid://A001/X11f/X30')
288+
X31 = (m83_data['Member ous id'] == 'uid://A002/X3216af/X31')
294289

295290
assert X30.sum() == 4 # Jul 13, 2020
296291
assert X31.sum() == 4 # Jul 13, 2020

astroquery/alma/utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from astropy import units as u
77
from astropy.coordinates import SkyCoord
8-
from astroquery.utils.commons import ASTROPY_LT_4_1
98

109
__all__ = ['parse_frequency_support', 'footprint_to_reg', 'approximate_primary_beam_sizes']
1110

@@ -48,8 +47,7 @@ def footprint_to_reg(footprint):
4847
-28.694332 266.521332 -28.699778'
4948
Some of them have *additional* polygons
5049
"""
51-
if ASTROPY_LT_4_1:
52-
footprint = footprint.decode('utf-8')
50+
5351
if footprint[:7] != 'Polygon' and footprint[:6] != 'Circle':
5452
raise ValueError("Unrecognized footprint type")
5553

astroquery/cadc/core.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,7 @@ def get_image_list(self, query_result, coordinates, radius):
457457
session=self.cadcdatalink._session)
458458
for service_def in datalink.bysemantics('#cutout'):
459459
access_url = service_def.access_url
460-
if isinstance(access_url, bytes): # ASTROPY_LT_4_1
461-
access_url = access_url.decode('ascii')
460+
462461
if '/sync' in access_url:
463462
service_params = service_def.input_params
464463
input_params = {param.name: param.value

astroquery/cadc/tests/test_cadctap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def get(*args, **kwargs):
206206
class CapsResponse:
207207
def __init__(self):
208208
self.status_code = 200
209-
self.content = b''
209+
self.content = ''
210210

211211
def raise_for_status(self):
212212
pass
@@ -286,7 +286,7 @@ def get(*args, **kwargs):
286286
class CapsResponse:
287287
def __init__(self):
288288
self.status_code = 200
289-
self.content = b''
289+
self.content = ''
290290

291291
def raise_for_status(self):
292292
pass
@@ -308,13 +308,13 @@ def __init__(self, **param_dict):
308308

309309
service_def1 = Mock()
310310
service_def1.access_url = \
311-
b'https://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/caom2ops/sync'
311+
'https://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/caom2ops/sync'
312312
service_def1.input_params = [Params(name='ID', value=uri),
313313
Params(name='RUNID', value=run_id)]
314314

315315
service_def2 = Mock()
316316
service_def2.access_url = \
317-
b'https://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/caom2ops/async'
317+
'https://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/caom2ops/async'
318318
service_def2.input_params = [Params(name='ID', value=uri),
319319
Params(name='RUNID', value=run_id)]
320320

astroquery/gaia/tests/test_gaiatap.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import astropy.units as u
3131
from astropy.coordinates.sky_coordinate import SkyCoord
3232
import numpy as np
33-
from astroquery.utils import ASTROPY_LT_4_1
3433
from astroquery.utils.tap.xmlparser import utils
3534
from astroquery.utils.tap.core import TapPlus
3635
from astroquery.utils.tap import taputils
@@ -50,8 +49,8 @@ def column_attrs():
5049
"table1_oid": np.int32
5150
}
5251
columns = {k: Column(name=k, description=k, dtype=v) for k, v in dtypes.items()}
53-
if not ASTROPY_LT_4_1:
54-
columns["source_id"].meta = {"_votable_string_dtype": "char"}
52+
53+
columns["source_id"].meta = {"_votable_string_dtype": "char"}
5554
return columns
5655

5756

astroquery/ipac/nexsci/nasa_exoplanet_archive/core.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,9 @@ def get_tap_tables():
115115
"""Tables accessed by API are gradually migrating to TAP service. Generate current list of tables in TAP."""
116116
tap = pyvo.dal.tap.TAPService(baseurl=conf.url_tap)
117117
response = tap.search(query="select * from TAP_SCHEMA.tables", language="ADQL")
118-
if not commons.ASTROPY_LT_4_1:
119-
tables = [table for table in response["table_name"].data if "TAP_SCHEMA." not in table]
120-
else:
121-
tables = [table.decode() for table in response["table_name"].data if b"TAP_SCHEMA." not in table]
118+
119+
tables = [table for table in response["table_name"].data if "TAP_SCHEMA." not in table]
120+
122121
return tables
123122

124123

astroquery/simbad/tests/test_simbad.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from ... import simbad
1212
from astroquery.utils.mocks import MockResponse
13-
from ...utils import commons
1413
from ...query import AstroQuery
1514
from ...exceptions import TableParseError
1615
from .test_simbad_remote import multicoords
@@ -440,6 +439,6 @@ def test_regression_issue388():
440439
response.content = f.read()
441440
parsed_table = simbad.Simbad._parse_result(response,
442441
simbad.core.SimbadVOTableResult)
443-
truth = b'M 1' if commons.ASTROPY_LT_4_1 else 'M 1'
442+
truth = 'M 1'
444443
assert parsed_table['MAIN_ID'][0] == truth
445444
assert len(parsed_table) == 1

astroquery/utils/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from .progressbar import chunk_report, chunk_read
77
from .class_or_instance import class_or_instance
88
from .commons import (parse_coordinates, TableList, suppress_vo_warnings,
9-
validate_email, ASTROPY_LT_4_1, ASTROPY_LT_4_3, ASTROPY_LT_5_0,
9+
validate_email, ASTROPY_LT_4_3, ASTROPY_LT_5_0,
1010
ASTROPY_LT_5_1)
1111
from .process_asyncs import async_to_sync
1212
from .docstr_chompers import prepend_docstr_nosections
@@ -19,7 +19,6 @@
1919
'TableList',
2020
'suppress_vo_warnings',
2121
'validate_email',
22-
'ASTROPY_LT_4_1',
2322
'ASTROPY_LT_4_3',
2423
'ASTROPY_LT_5_0',
2524
'ASTROPY_LT_5_1',

astroquery/utils/commons.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@
2929
'TableList',
3030
'suppress_vo_warnings',
3131
'validate_email',
32-
'ASTROPY_LT_4_1',
3332
'ASTROPY_LT_4_3',
3433
'ASTROPY_LT_5_0',
3534
'ASTROPY_LT_5_1']
3635

37-
ASTROPY_LT_4_1 = not minversion('astropy', '4.1')
3836
ASTROPY_LT_4_3 = not minversion('astropy', '4.3')
3937
ASTROPY_LT_5_0 = not minversion('astropy', '5.0')
4038

0 commit comments

Comments
 (0)