5
5
import pytest
6
6
import requests
7
7
from requests import ReadTimeout
8
+ from numpy .testing import assert_allclose
8
9
9
10
from astropy .table import Table
10
11
from astropy .units import arcsec , arcmin
11
- from astropy .io import ascii
12
12
13
13
from astropy .coordinates import SkyCoord
14
14
@@ -37,12 +37,15 @@ def test_is_xmatch_up():
37
37
def remote_table (tmp_path_factory ):
38
38
# this can be used to check that the API is still functional & doing as expected
39
39
infile = DATA_DIR / "posList.csv"
40
- outfile = tmp_path_factory .mktemp ("remote_data" ) / "http_result.csv "
41
- os .system ("curl -X POST -F request=xmatch -F distMaxArcsec=5 -F RESPONSEFORMAT=csv "
40
+ outfile = tmp_path_factory .mktemp ("remote_data" ) / "http_result.vot "
41
+ os .system ("curl -X POST -F request=xmatch -F distMaxArcsec=5 -F RESPONSEFORMAT=votable "
42
42
"-F cat1=@{1} -F colRA1=ra -F colDec1=dec -F cat2=vizier:II/246/out "
43
43
"http://cdsxmatch.u-strasbg.fr/xmatch/api/v1/sync > {0}" .
44
44
format (outfile , infile ))
45
- return ascii .read (outfile , format = "csv" , fast_reader = False )
45
+ remote_table = Table .read (outfile , format = "votable" )
46
+ remote_table .rename_column ('_2MASS' , '2MASS' )
47
+
48
+ return remote_table
46
49
47
50
48
51
@pytest .mark .remote_data
@@ -83,7 +86,11 @@ def test_xmatch_query(self, xmatch, remote_table):
83
86
'e_Jmag' , 'e_Hmag' , 'e_Kmag' , 'Qfl' , 'Rfl' , 'X' , 'MeasureJD' ]
84
87
assert len (table ) == 11
85
88
86
- assert all (table == remote_table )
89
+ for col in table .colnames :
90
+ if remote_table [col ].dtype .kind == 'U' :
91
+ assert all (table [col ] == remote_table [col ])
92
+ else :
93
+ assert_allclose (table [col ], remote_table [col ])
87
94
88
95
def test_xmatch_query_astropy_table (self , xmatch , remote_table ):
89
96
input_table = Table .read (DATA_DIR / "posList.csv" , format = "ascii.csv" )
@@ -99,8 +106,11 @@ def test_xmatch_query_astropy_table(self, xmatch, remote_table):
99
106
'errHalfMaj' , 'errHalfMin' , 'errPosAng' , 'Jmag' , 'Hmag' , 'Kmag' ,
100
107
'e_Jmag' , 'e_Hmag' , 'e_Kmag' , 'Qfl' , 'Rfl' , 'X' , 'MeasureJD' ]
101
108
assert len (table ) == 11
102
-
103
- assert all (table == remote_table )
109
+ for col in table .colnames :
110
+ if remote_table [col ].dtype .kind == 'U' :
111
+ assert all (table [col ] == remote_table [col ])
112
+ else :
113
+ assert_allclose (table [col ], remote_table [col ])
104
114
105
115
@pytest .mark .skipif ('regions' not in sys .modules ,
106
116
reason = "requires astropy-regions" )
0 commit comments