Skip to content

Commit

Permalink
MAINT: cleanup workarounds for pivot <1.5 versions
Browse files Browse the repository at this point in the history
  • Loading branch information
bsipocz committed May 3, 2024
1 parent 46d512a commit facd20b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 36 deletions.
7 changes: 1 addition & 6 deletions astroquery/alma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
from astropy import units as u
from astropy.time import Time

try:
from pyvo.dal.sia2 import SIA2_PARAMETERS_DESC, SIA2Service
except ImportError:
# Can be removed once min version of pyvo is 1.5
from pyvo.dal.sia2 import SIA_PARAMETERS_DESC as SIA2_PARAMETERS_DESC
from pyvo.dal.sia2 import SIAService as SIA2Service
from pyvo.dal.sia2 import SIA2_PARAMETERS_DESC, SIA2Service

from ..exceptions import LoginError
from ..utils import commons
Expand Down
9 changes: 2 additions & 7 deletions astroquery/alma/tests/test_alma_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
from astropy import units as u
import numpy as np
import pytest
try:
# This requires pyvo 1.4
from pyvo.dal.exceptions import DALOverflowWarning
except ImportError:
pass

from pyvo.dal.exceptions import DALOverflowWarning

from astroquery.exceptions import CorruptDataWarning
from .. import Alma
Expand Down Expand Up @@ -52,7 +49,6 @@ def alma(request):
@pytest.mark.remote_data
class TestAlma:
def test_public(self, alma):
# This warning was added in pyvo 1.4, but we don't test older versions with remote-data
with pytest.warns(expected_warning=DALOverflowWarning,
match="Partial result set. Potential causes MAXREC, async storage space, etc."):
results = alma.query(payload=None, public=True, maxrec=100)
Expand Down Expand Up @@ -88,7 +84,6 @@ def test_freq(self, alma):
def test_bands(self, alma):
payload = {'band_list': ['5', '7']}
# Added maxrec here as downloading and reading the results take too long.
# This warning was added in pyvo 1.4, but we don't test older versions with remote-data
with pytest.warns(expected_warning=DALOverflowWarning,
match="Partial result set. Potential causes MAXREC, async storage space, etc."):
result = alma.query(payload, maxrec=1000)
Expand Down
7 changes: 1 addition & 6 deletions astroquery/ipac/irsa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@

from pyvo.dal import TAPService

try:
from pyvo.dal.sia2 import SIA2Service, SIA2_PARAMETERS_DESC
except ImportError:
# Can be removed once min version of pyvo is 1.5
from pyvo.dal.sia2 import SIA_PARAMETERS_DESC as SIA2_PARAMETERS_DESC
from pyvo.dal.sia2 import SIAService as SIA2Service
from pyvo.dal.sia2 import SIA2Service, SIA2_PARAMETERS_DESC

from astroquery import log
from astroquery.query import BaseVOQuery
Expand Down
6 changes: 1 addition & 5 deletions astroquery/ipac/irsa/tests/test_irsa_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
from astropy.coordinates import SkyCoord
from astropy.utils.exceptions import AstropyDeprecationWarning

try:
# This requires pyvo 1.4
from pyvo.dal.exceptions import DALOverflowWarning
except ImportError:
pass
from pyvo.dal.exceptions import DALOverflowWarning

from astroquery.ipac.irsa import Irsa

Expand Down
17 changes: 5 additions & 12 deletions astroquery/simbad/tests/test_simbad_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@
# Maybe we need to expose SimbadVOTableResult to be in the public API?
from astroquery.simbad.core import SimbadVOTableResult
from astroquery.exceptions import BlankResponseWarning
from packaging import version
from pyvo import __version__ as pyvo_version
try:
# This requires pyvo 1.4
from pyvo.dal.exceptions import DALOverflowWarning
except ImportError:
pass

from pyvo.dal.exceptions import DALOverflowWarning


# M42 coordinates
Expand Down Expand Up @@ -273,11 +268,9 @@ def test_query_tap(self):
expect = "letters numbers\n------- -------\n a 1\n b 2\n c 3"
assert expect == str(result)
# Test query_tap raised errors
# DALOverflowWarning exists since pyvo 1.4
if version.parse(pyvo_version) > version.parse('1.4'):
with pytest.raises(DALOverflowWarning, match="Partial result set *"):
truncated_result = Simbad.query_tap("SELECT * from basic", maxrec=2)
assert len(truncated_result) == 2
with pytest.raises(DALOverflowWarning, match="Partial result set *"):
truncated_result = Simbad.query_tap("SELECT * from basic", maxrec=2)
assert len(truncated_result) == 2
with pytest.raises(ValueError, match="The maximum number of records cannot exceed 2000000."):
Simbad.query_tap("select top 5 * from basic", maxrec=10e10)
with pytest.raises(ValueError, match="Query string contains an odd number of single quotes.*"):
Expand Down

0 comments on commit facd20b

Please sign in to comment.