Skip to content

Commit 9e85f4e

Browse files
committed
refactor: switch to public API in remote tests
1 parent 4e6f0ee commit 9e85f4e

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

astroquery/vizier/tests/test_vizier_remote.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import astropy.units as u
66
from astropy.coordinates import SkyCoord
77

8-
from astroquery import vizier
8+
from astroquery.vizier import Vizier
99
from astroquery.utils import commons
1010
from .conftest import scalar_skycoord, vector_skycoord
1111

@@ -14,110 +14,110 @@
1414
class TestVizierRemote:
1515

1616
def test_query_object(self):
17-
result = vizier.core.Vizier.query_object(
17+
result = Vizier.query_object(
1818
"HD 226868", catalog=["NOMAD", "UCAC"])
1919

2020
assert isinstance(result, commons.TableList)
2121

2222
def test_query_another_object(self):
23-
result = vizier.core.Vizier.query_region(
23+
result = Vizier.query_region(
2424
"AFGL 2591", radius='0d5m', catalog="B/iram/pdbi")
2525
assert isinstance(result, commons.TableList)
2626

2727
def test_query_object_async(self):
28-
response = vizier.core.Vizier.query_object_async(
28+
response = Vizier.query_object_async(
2929
"HD 226868", catalog=["NOMAD", "UCAC"])
3030
assert response is not None
3131

3232
def test_query_region(self):
33-
result = vizier.core.Vizier.query_region(
33+
result = Vizier.query_region(
3434
scalar_skycoord, radius=5 * u.deg, catalog=["HIP", "NOMAD", "UCAC"])
3535

3636
assert isinstance(result, commons.TableList)
3737

3838
def test_query_region_async(self):
39-
response = vizier.core.Vizier.query_region_async(
39+
response = Vizier.query_region_async(
4040
scalar_skycoord, radius=5 * u.deg, catalog=["HIP", "NOMAD", "UCAC"])
4141
assert response is not None
4242

4343
def test_query_region_async_galactic(self):
44-
response = vizier.core.Vizier.query_region_async(
44+
response = Vizier.query_region_async(
4545
scalar_skycoord, radius=0.5 * u.deg, catalog="HIP", frame="galactic")
4646
assert response is not None
47-
payload = vizier.core.Vizier.query_region_async(
47+
payload = Vizier.query_region_async(
4848
scalar_skycoord, radius=0.5 * u.deg, catalog="HIP",
4949
frame="galactic", get_query_payload=True)
5050
assert "-c=G" in payload
5151

5252
def test_query_Vizier_instance(self):
5353
with pytest.warns(UserWarning, match="xry : No such keyword"):
54-
v = vizier.core.Vizier(
54+
vizier = Vizier(
5555
columns=['_RAJ2000', 'DEJ2000', 'B-V', 'Vmag', 'Plx'],
5656
column_filters={"Vmag": ">10"}, keywords=["optical", "xry"])
5757

58-
result = v.query_object("HD 226868", catalog=["NOMAD", "UCAC"])
58+
result = vizier.query_object("HD 226868", catalog=["NOMAD", "UCAC"])
5959
assert isinstance(result, commons.TableList)
60-
result = v.query_region(
60+
result = vizier.query_region(
6161
scalar_skycoord, width="5d0m0s", height="3d0m0s", catalog=["NOMAD", "UCAC"])
6262
assert isinstance(result, commons.TableList)
6363

6464
def test_vizier_column_restriction(self):
6565
# Check that the column restriction worked. At least some of these
6666
# catalogs include Bmag's
67-
v = vizier.core.Vizier(
67+
vizier = Vizier(
6868
columns=['_RAJ2000', 'DEJ2000', 'B-V', 'Vmag', 'Plx'],
6969
column_filters={"Vmag": ">10"}, keywords=["optical", "X-ray"])
7070

71-
result = v.query_object("HD 226868", catalog=["NOMAD", "UCAC"])
71+
result = vizier.query_object("HD 226868", catalog=["NOMAD", "UCAC"])
7272
for table in result:
7373
assert 'Bmag' not in table.columns
7474

7575
@pytest.mark.parametrize('all', ('all', '*'))
7676
def test_alls_withaddition(self, all):
7777
# Check that all the expected columns are there plus the _r
7878
# (radius from target) that we've added
79-
v = vizier.core.Vizier(columns=[all, "+_r"], catalog="II/246")
80-
result = v.query_region("HD 226868", radius="20s")
79+
vizier = Vizier(columns=[all, "+_r"], catalog="II/246")
80+
result = vizier.query_region("HD 226868", radius="20s")
8181
table = result['II/246/out']
8282
assert 'Jmag' in table.columns
8383
assert '_r' in table.columns
8484

8585
def test_get_catalogs(self):
86-
result = vizier.core.Vizier.get_catalogs('J/ApJ/706/83')
86+
result = Vizier.get_catalogs('J/ApJ/706/83')
8787
assert isinstance(result, commons.TableList)
8888

8989
def test_get_catalog_metadata(self):
90-
meta = vizier.core.Vizier(catalog="I/324").get_catalog_metadata()
90+
meta = Vizier(catalog="I/324").get_catalog_metadata()
9191
assert meta['title'] == "The Initial Gaia Source List (IGSL)"
9292

9393
def test_query_two_wavelengths(self):
94-
v = vizier.core.Vizier(
94+
vizier = Vizier(
9595
columns=['_RAJ2000', 'DEJ2000', 'B-V', 'Vmag', 'Plx'],
9696
column_filters={"Vmag": ">10"}, keywords=["optical", "radio"])
97-
v.ROW_LIMIT = 1
98-
v.query_object('M 31')
97+
vizier.ROW_LIMIT = 1
98+
vizier.query_object('M 31')
9999

100100
def test_regressiontest_invalidtable(self):
101-
V = vizier.core.Vizier(
101+
vizier = Vizier(
102102
columns=['all'], ucd='(spect.dopplerVeloc*|phys.veloc*)',
103103
keywords=['Radio', 'IR'], row_limit=5000)
104-
C = SkyCoord(359.61687 * u.deg, -0.242457 * u.deg, frame="galactic")
104+
coordinate = SkyCoord(359.61687 * u.deg, -0.242457 * u.deg, frame="galactic")
105105

106106
# With newer versions UnitsWarning may be issued as well
107-
with pytest.warns() as w:
108-
V.query_region(C, radius=2 * u.arcmin)
107+
with pytest.warns() as warnings:
108+
vizier.query_region(coordinate, radius=2 * u.arcmin)
109109

110-
for i in w:
110+
for i in warnings:
111111
message = str(i.message)
112112
assert ("VOTABLE parsing raised exception" in message or "not supported by the VOUnit standard" in message)
113113

114114
def test_multicoord(self):
115115

116116
# Regression test: the columns of the default should never
117117
# be modified from default
118-
assert vizier.core.Vizier.columns == ['*']
118+
assert Vizier.columns == ['*']
119119
# Coordinate selection is entirely arbitrary
120-
result = vizier.core.Vizier.query_region(
120+
result = Vizier.query_region(
121121
vector_skycoord, radius=10 * u.arcsec, catalog=["HIP", "NOMAD", "UCAC"])
122122

123123
assert len(result) >= 5
@@ -126,31 +126,31 @@ def test_multicoord(self):
126126
assert result['I/239/hip_main']['HIP'] == 98298
127127

128128
def test_findcatalog_maxcatalog(self):
129-
V = vizier.core.Vizier()
130-
cats = V.find_catalogs('eclipsing binary planets', max_catalogs=5000)
129+
vizier = Vizier()
130+
cats = vizier.find_catalogs('eclipsing binary planets', max_catalogs=5000)
131131
assert len(cats) >= 39 # as of 2024
132132

133133
def test_findcatalog_ucd(self):
134134
# this fails for VizieR 7.33.3, should work in next releases
135-
V = vizier.core.Vizier()
136-
ucdresult = V(ucd='phys.albedo').find_catalogs('mars', max_catalogs=5000)
137-
result = V.find_catalogs('mars', max_catalogs=5000)
135+
vizier = Vizier()
136+
ucdresult = vizier(ucd='phys.albedo').find_catalogs('mars', max_catalogs=5000)
137+
result = vizier.find_catalogs('mars', max_catalogs=5000)
138138

139139
assert len(ucdresult) >= 1
140140
assert len(result) >= 11
141141
# important part: we're testing that UCD is parsed and some catalogs are ruled out
142142
assert len(ucdresult) < len(result)
143143

144144
def test_asu_tsv_return_type(self):
145-
V = vizier.core.Vizier()
146-
result = V.query_object("HD 226868", catalog=["NOMAD", "UCAC"], return_type='asu-tsv', cache=False)
145+
vizier = Vizier()
146+
result = vizier.query_object("HD 226868", catalog=["NOMAD", "UCAC"], return_type='asu-tsv', cache=False)
147147

148148
assert isinstance(result, list)
149149
assert len(result) == 3
150150

151151
def test_query_constraints(self):
152-
V = vizier.core.Vizier(row_limit=3)
153-
result = V.query_constraints(catalog="I/130/main", mB2="=14.7")[0]
152+
vizier = Vizier(row_limit=3)
153+
result = vizier.query_constraints(catalog="I/130/main", mB2="=14.7")[0]
154154
# row_limit is taken in account
155155
assert len(result) == 3
156156
# the criteria is respected

0 commit comments

Comments
 (0)