Skip to content

Commit 4362450

Browse files
authored
Merge pull request #2518 from bsipocz/warnings_remove_ignore_np_deprecation
BUG: Fix SDSS parsing to directly use Table.read
2 parents a3d9b7a + 43926ec commit 4362450

File tree

3 files changed

+8
-38
lines changed

3 files changed

+8
-38
lines changed

astroquery/sdss/core.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -896,21 +896,15 @@ def _parse_result(self, response, verbose=False):
896896
table : `~astropy.table.Table`
897897
898898
"""
899+
if 'error_message' in response.text:
900+
raise RemoteServiceError(response.text)
899901

900-
if 'error_message' in io.BytesIO(response.content):
901-
raise RemoteServiceError(response.content)
902-
skip_header = 0
903-
if response.content.startswith(b'#Table'):
904-
skip_header = 1
905-
arr = np.atleast_1d(np.genfromtxt(io.BytesIO(response.content),
906-
names=True, dtype=None,
907-
delimiter=',', skip_header=skip_header,
908-
comments='#'))
902+
arr = Table.read(response.text, format='ascii.csv', comment="#")
909903

910904
if len(arr) == 0:
911905
return None
912906
else:
913-
return Table(arr)
907+
return arr
914908

915909
def _args_to_payload(self, coordinates=None,
916910
fields=None, spectro=False, region=False,

astroquery/sdss/tests/test_sdss.py

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ def url_tester_crossid(data_release):
144144

145145
def compare_xid_data(xid, data):
146146
for col in xid.colnames:
147-
if xid[col].dtype.type is np.string_:
148-
assert xid[col] == data[col]
147+
if xid[col].dtype.type is np.str_:
148+
assert all(xid[col] == data[col])
149149
else:
150150
assert_allclose(xid[col], data[col])
151151

@@ -196,10 +196,7 @@ class = 'galaxy'
196196
xid = sdss.SDSS.query_sql(query, data_release=dr)
197197
data = Table.read(data_path(DATA_FILES['images_id']),
198198
format='ascii.csv', comment='#')
199-
# The following line is needed for systems where the default integer type
200-
# is int32, the column will then be interpreted as string which makes the
201-
# test fail.
202-
data['objid'] = data['objid'].astype(np.int64)
199+
203200
compare_xid_data(xid, data)
204201
url_tester(dr)
205202

@@ -237,11 +234,7 @@ def test_sdss_specobj(patch_request, dr):
237234
xid = sdss.SDSS.query_specobj(plate=2340, data_release=dr)
238235
data = Table.read(data_path(DATA_FILES['spectra_id']),
239236
format='ascii.csv', comment='#')
240-
# The following line is needed for systems where the default integer type
241-
# is int32, the column will then be interpreted as string which makes the
242-
# test fail.
243-
data['specobjid'] = data['specobjid'].astype(np.int64)
244-
data['objid'] = data['objid'].astype(np.int64)
237+
245238
compare_xid_data(xid, data)
246239
url_tester(dr)
247240

@@ -252,10 +245,6 @@ def test_sdss_photoobj(patch_request, dr):
252245
run=1904, camcol=3, field=164, data_release=dr)
253246
data = Table.read(data_path(DATA_FILES['images_id']),
254247
format='ascii.csv', comment='#')
255-
# The following line is needed for systems where the default integer type
256-
# is int32, the column will then be interpreted as string which makes the
257-
# test fail.
258-
data['objid'] = data['objid'].astype(np.int64)
259248
compare_xid_data(xid, data)
260249
url_tester(dr)
261250

@@ -265,10 +254,6 @@ def test_list_coordinates(patch_request, dr):
265254
xid = sdss.SDSS.query_region(coords_list, data_release=dr)
266255
data = Table.read(data_path(DATA_FILES['images_id']),
267256
format='ascii.csv', comment='#')
268-
# The following line is needed for systems where the default integer type
269-
# is int32, the column will then be interpreted as string which makes the
270-
# test fail.
271-
data['objid'] = data['objid'].astype(np.int64)
272257
compare_xid_data(xid, data)
273258
url_tester_crossid(dr)
274259

@@ -278,10 +263,6 @@ def test_column_coordinates(patch_request, dr):
278263
xid = sdss.SDSS.query_region(coords_column, data_release=dr)
279264
data = Table.read(data_path(DATA_FILES['images_id']),
280265
format='ascii.csv', comment='#')
281-
# The following line is needed for systems where the default integer type
282-
# is int32, the column will then be interpreted as string which makes the
283-
# test fail.
284-
data['objid'] = data['objid'].astype(np.int64)
285266
compare_xid_data(xid, data)
286267
url_tester_crossid(dr)
287268

@@ -306,10 +287,6 @@ def test_query_crossid(patch_request, dr):
306287
xid = sdss.SDSS.query_crossid(coords_column, data_release=dr)
307288
data = Table.read(data_path(DATA_FILES['images_id']),
308289
format='ascii.csv', comment='#')
309-
# The following line is needed for systems where the default integer type
310-
# is int32, the column will then be interpreted as string which makes the
311-
# test fail.
312-
data['objid'] = data['objid'].astype(np.int64)
313290
compare_xid_data(xid, data)
314291
url_tester_crossid(dr)
315292

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ filterwarnings =
3939
# This is a temporary measure, all of these should be fixed:
4040
ignore:distutils Version classes are deprecated:DeprecationWarning
4141
ignore::pytest.PytestUnraisableExceptionWarning
42-
ignore::numpy.VisibleDeprecationWarning
4342
ignore:unclosed <ssl.SSLSocket:ResourceWarning
4443
ignore::UserWarning
4544
ignore::astroquery.exceptions.InputWarning

0 commit comments

Comments
 (0)