Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: make XMatch prepare tables error message state the two possible causes for failure #3168

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ xmatch
- Fix xmatch query for two local tables. The second table was written over the first one,
resulting in a confusing "missing cat1" error. [#3116]

- Make the error message clearer about VizieR tables not available for
crossmatching [#3168]


0.4.7 (2024-03-08)
==================
Expand Down
7 changes: 6 additions & 1 deletion astroquery/xmatch/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ def _prepare_sending_table(self, cat_index, payload, kwargs, cat, colRA, colDec)

if not self.is_table_available(cat):
if ((colRA is None) or (colDec is None)):
raise ValueError('Specify the name of the RA/Dec columns in the input table.')
raise ValueError(
f"'{cat}' is not available on the XMatch server. If you are "
"using a VizieR table name, note that only tables with "
"coordinates are available on the XMatch server. If you are "
f"using a local table, the arguments 'colRA{cat_index}' and "
f"'colDec{cat_index}' must be provided.")
# if `cat1` is not a VizieR table,
# it is assumed it's either a URL or an uploaded table
payload['colRA{0}'.format(cat_index)] = colRA
Expand Down
11 changes: 11 additions & 0 deletions astroquery/xmatch/tests/test_xmatch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from pathlib import Path
import re

import requests
import pytest
Expand Down Expand Up @@ -114,3 +115,13 @@ def test_two_local_tables():
max_distance=1 * arcsec,
get_query_payload=True)
assert 'cat1' in payload[1]["files"] and 'cat2' in payload[1]["files"]


def test_table_not_available(monkeypatch):
xm = XMatch()
monkeypatch.setattr(xm, '_request', request_mockreturn)
cat1 = "vizier:J/A+A/331/81/table2"
cat2 = "blabla"
# reproduces #1464
with pytest.raises(ValueError, match=f"'{re.escape(cat1)}' is not available *"):
xm.query_async(cat1=cat1, cat2=cat2, max_distance=5 * arcsec)