File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 78
78
79
79
- Change URL to https. [#2108]
80
80
81
+ - A ``NoResultsWarning `` is now returned when there is return of any empty
82
+ table. [#1837]
83
+
81
84
82
85
Infrastructure, Utility and Other Changes and Additions
83
86
-------------------------------------------------------
Original file line number Diff line number Diff line change 3
3
import os
4
4
import io
5
5
import requests
6
+ import warnings
6
7
import numpy as np
7
8
from astropy .table import Table
8
9
import astropy .io .fits as fits
9
-
10
+ from .. exceptions import NoResultsWarning
10
11
11
12
__all__ = ['query' , 'save_file' , 'get_file' ]
12
13
id_parse = re .compile (r'ID\=(\d+)' )
@@ -144,7 +145,12 @@ def parse_line(line, cs=cs):
144
145
dtypes = _map_dtypes (type_names , field_widths )
145
146
# To table
146
147
# transpose data for appropriate table instance handling
147
- table = Table (list (zip (* data )), names = col_names , dtype = dtypes )
148
+
149
+ if len (data ) > 0 :
150
+ table = Table (list (zip (* data )), names = col_names , dtype = dtypes )
151
+ else :
152
+ warnings .warn (NoResultsWarning ("No matching rows were found in the query." ))
153
+ table = Table ()
148
154
return table
149
155
150
156
Original file line number Diff line number Diff line change
1
+ import pytest
2
+
3
+ from astropy .table import Table
4
+
5
+ from astroquery import sha
6
+ from astroquery .exceptions import NoResultsWarning
7
+
8
+
9
+ @pytest .mark .remote_data
10
+ def test_query_no_results ():
11
+ # Test for issue #1836
12
+ with pytest .warns (NoResultsWarning ):
13
+ result = sha .query (ra = 219.57741 , dec = 64.171525 , size = 0.001 )
14
+
15
+ assert isinstance (result , Table )
16
+ assert len (result ) == 0
You can’t perform that action at this time.
0 commit comments