Skip to content

Commit f94a3fc

Browse files
committed
fix ALMA utility tests and warning checkers to handle byte type indices
and log.warning not raising real warnings
1 parent 3321aa5 commit f94a3fc

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

astroquery/alma/tests/test_alma_remote.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ def test_m83(self, temp_dir, recwarn):
7878
#assert ex.value.args[0] == ('Received an error 405: this may indicate you have '
7979
# 'already staged the data. Try downloading the '
8080
# 'file URLs directly with download_files.')
81-
link_list = alma.stage_data(uids)
82-
w = recwarn.pop()
83-
assert (str(w.message) == ('Error 405 received. If you have previously staged the '
84-
'same UIDs, the result returned is probably correct,'
85-
' otherwise you may need to create a fresh astroquery.Alma instance.'))
81+
82+
# log.warning doesn't actually make a warning
83+
#link_list = alma.stage_data(uids)
84+
#w = recwarn.pop()
85+
#assert (str(w.message) == ('Error 405 received. If you have previously staged the '
86+
# 'same UIDs, the result returned is probably correct,'
87+
# ' otherwise you may need to create a fresh astroquery.Alma instance.'))
8688

8789
def test_stage_data(self, temp_dir, recwarn):
8890
alma = Alma()
@@ -110,11 +112,13 @@ def test_stage_data(self, temp_dir, recwarn):
110112
#assert ex.value.args[0] == ('Received an error 405: this may indicate you have '
111113
# 'already staged the data. Try downloading the '
112114
# 'file URLs directly with download_files.')
113-
result = alma.stage_data([uid])
114-
w = recwarn.pop()
115-
assert (str(w.message) == ('Error 405 received. If you have previously staged the '
116-
'same UIDs, the result returned is probably correct,'
117-
' otherwise you may need to create a fresh astroquery.Alma instance.'))
115+
116+
# log.warning doesn't actually make a warning
117+
#result = alma.stage_data([uid])
118+
#w = recwarn.pop()
119+
#assert (str(w.message) == ('Error 405 received. If you have previously staged the '
120+
# 'same UIDs, the result returned is probably correct,'
121+
# ' otherwise you may need to create a fresh astroquery.Alma instance.'))
118122

119123

120124
def test_doc_example(self, temp_dir):

astroquery/alma/tests/test_alma_utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ def test_make_finder_chart():
7070
'Eta Carinae')
7171
image, catalog, hit_mask_public, hit_mask_private = result
7272

73-
assert len(catalog) >= 7
74-
assert 3 in hit_mask_public
73+
assert len(catalog) >= 6 # down to 6 on Nov 17, 2016
74+
assert 3 in [int(x) for x in hit_mask_public]
7575
# Feb 8 2016: apparently the 60s integration hasn't actually been released yet...
76-
assert hit_mask_public[3][256,256] >= 30.23
76+
if 3 in hit_mask_public:
77+
assert hit_mask_public[3][256,256] >= 30.23
78+
elif b'3' in hit_mask_public:
79+
assert hit_mask_public[b'3'][256,256] >= 30.23
80+
else:
81+
raise ValueError("hit_mask keys are not of any known type")

astroquery/alma/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,13 +441,13 @@ def make_finder_chart_from_image_and_catalog(image, catalog, save_prefix,
441441
fig.show_contour(fits.PrimaryHDU(data=hit_mask_public[band],
442442
header=image.header),
443443
levels=integration_time_contour_levels,
444-
colors=[band_colors_pub[band]] * len(integration_time_contour_levels),
444+
colors=[band_colors_pub[int(band)]] * len(integration_time_contour_levels),
445445
convention='calabretta')
446446
if band in hit_mask_private:
447447
fig.show_contour(fits.PrimaryHDU(data=hit_mask_private[band],
448448
header=image.header),
449449
levels=integration_time_contour_levels,
450-
colors=[band_colors_priv[band]] * len(integration_time_contour_levels),
450+
colors=[band_colors_priv[int(band)]] * len(integration_time_contour_levels),
451451
convention='calabretta')
452452

453453
fig.save('{0}_almafinderchart.png'.format(save_prefix))

0 commit comments

Comments
 (0)