From e4474616a72059f5859ba82f9dcbc3dfd25f2f4c Mon Sep 17 00:00:00 2001 From: MARCHAND MANON Date: Tue, 7 Jan 2025 12:26:30 +0100 Subject: [PATCH 1/2] doc: make the error message state the two possible causes for failure either the catalog is not available (no coordinates or typo in the name) or the user has to specify colRa and colDec --- CHANGES.rst | 3 +++ astroquery/xmatch/core.py | 7 ++++++- astroquery/xmatch/tests/test_xmatch.py | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 80dfdf76a3..390c5ab8c5 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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) ================== diff --git a/astroquery/xmatch/core.py b/astroquery/xmatch/core.py index 57cc954995..7268d39434 100644 --- a/astroquery/xmatch/core.py +++ b/astroquery/xmatch/core.py @@ -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 diff --git a/astroquery/xmatch/tests/test_xmatch.py b/astroquery/xmatch/tests/test_xmatch.py index d1c9899a86..8c303516ac 100644 --- a/astroquery/xmatch/tests/test_xmatch.py +++ b/astroquery/xmatch/tests/test_xmatch.py @@ -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 @@ -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) From a14a28f817a6e88836ce842aa190569f735de333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Tue, 7 Jan 2025 11:18:41 -0800 Subject: [PATCH 2/2] Fix typo [skip ci] --- astroquery/xmatch/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astroquery/xmatch/core.py b/astroquery/xmatch/core.py index 7268d39434..051f07a2f5 100644 --- a/astroquery/xmatch/core.py +++ b/astroquery/xmatch/core.py @@ -147,7 +147,7 @@ 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( - f"'{cat}' is not available on the XMatch server.If you are " + 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 "