Skip to content

Commit 8c84b28

Browse files
committed
fix: add uploadlimit from capabilities rather than hardcoding it
1 parent 59a2d42 commit 8c84b28

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

astroquery/simbad/core.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def __init__(self, ROW_LIMIT=None):
108108
self._server = conf.server
109109
self._tap = None
110110
self._hardlimit = None
111+
self._uploadlimit = None
111112
# attributes to construct ADQL queries
112113
self._columns_in_output = None # a list of _Column
113114
self.joins = [] # a list of _Join
@@ -166,6 +167,12 @@ def hardlimit(self):
166167
self._hardlimit = self.tap.hardlimit
167168
return self._hardlimit
168169

170+
@property
171+
def uploadlimit(self):
172+
if self._uploadlimit is None:
173+
self._uploadlimit = self.tap.get_tap_capability().uploadlimit.hard.content
174+
return self._uploadlimit
175+
169176
@property
170177
def columns_in_output(self):
171178
"""A list of _Column.
@@ -780,9 +787,9 @@ def query_region(self, coordinates, radius=2*u.arcmin, *,
780787

781788
# from uploadLimit in SIMBAD's capabilities
782789
# http://simbad.cds.unistra.fr/simbad/sim-tap/capabilities
783-
if len(center) > 200000:
784-
raise ValueError("'query_region' can process up to 200000 centers. For "
785-
"larger queries, split your centers list.")
790+
if len(center) > self.uploadlimit:
791+
raise ValueError(f"'query_region' can process up to {self.uploadlimit} "
792+
"centers. For larger queries, split your centers list.")
786793

787794
# `radius` as `str` is iterable, but contains only one value.
788795
if isiterable(radius) and not isinstance(radius, str):

astroquery/simbad/tests/test_simbad.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def _mock_simbad_class(monkeypatch):
3333
# >>> options = Simbad.list_votable_fields()
3434
# >>> options.write("simbad_output_options.xml", format="votable")
3535
monkeypatch.setattr(simbad.SimbadClass, "hardlimit", 2000000)
36+
monkeypatch.setattr(simbad.SimbadClass, "uploadlimit", 200000)
3637
monkeypatch.setattr(simbad.SimbadClass, "list_votable_fields", lambda self: table)
3738

3839

@@ -151,6 +152,8 @@ def test_mocked_simbad():
151152
assert len(options) >= 115
152153
# this mocks the hardlimit
153154
assert simbad_instance.hardlimit == 2000000
155+
# and the uploadlimit
156+
assert simbad_instance.uploadlimit == 200000
154157

155158
# ----------------------------
156159
# Test output options settings

0 commit comments

Comments
 (0)