From 5ecfa95516410f322befff1d01fe2411e2046c25 Mon Sep 17 00:00:00 2001 From: Abdu Zoghbi Date: Mon, 6 Jan 2025 17:35:10 -0500 Subject: [PATCH] fix table->catalog in remote tests --- astroquery/heasarc/core.py | 18 ++--- astroquery/heasarc/tests/test_heasarc.py | 2 +- .../heasarc/tests/test_heasarc_remote.py | 76 +++++++++---------- 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/astroquery/heasarc/core.py b/astroquery/heasarc/core.py index 8034810f5b..c6e0c9908e 100644 --- a/astroquery/heasarc/core.py +++ b/astroquery/heasarc/core.py @@ -420,7 +420,7 @@ def query_region(self, position=None, catalog=None, radius=None, *, # save the response in case we want to use it later self._query_result = response - self._catalogname = catalog + self._catalog_name = catalog table = response.to_table() if 'search_offset_' in table.colnames: @@ -459,7 +459,7 @@ def query_object(self, object_name, mission, *, return self.query_region(pos, catalog=mission, spatial='cone', get_query_payload=get_query_payload) - def get_datalinks(self, query_result=None, catalogname=None): + def get_datalinks(self, query_result=None, catalog_name=None): """Get links to data products Use vo/datalinks to query the data products for some query_results. @@ -469,7 +469,7 @@ def get_datalinks(self, query_result=None, catalogname=None): A table that contain the search results. Typically as returned by query_region. If None, use the table from the most recent query_region call. - catalogname : str + catalog_name : str The catalog name for the which the query_result belongs to. If None, use the one from the most recent query_region call. @@ -496,16 +496,16 @@ def get_datalinks(self, query_result=None, catalogname=None): 'query_result needs to be the output of ' 'query_region or a subset.') - if catalogname is None: - catalogname = self._catalogname + if catalog_name is None: + catalog_name = self._catalog_name if not ( - isinstance(catalogname, str) - and catalogname in self.tap.tables.keys() + isinstance(catalog_name, str) + and catalog_name in self.tap.tables.keys() ): - raise ValueError(f'Unknown catalog name: {catalogname}') + raise ValueError(f'Unknown catalog name: {catalog_name}') # datalink url - dlink_url = f'{self.VO_URL}/datalink/{catalogname}' + dlink_url = f'{self.VO_URL}/datalink/{catalog_name}' query = pyvo.dal.adhoc.DatalinkQuery( baseurl=dlink_url, diff --git a/astroquery/heasarc/tests/test_heasarc.py b/astroquery/heasarc/tests/test_heasarc.py index 006dda51b8..980be6ac3a 100644 --- a/astroquery/heasarc/tests/test_heasarc.py +++ b/astroquery/heasarc/tests/test_heasarc.py @@ -163,7 +163,7 @@ def test_get_datalink(): Heasarc.get_datalinks([1, 2]) with pytest.raises(ValueError, match="No __row column found"): - Heasarc.get_datalinks(Table({"id": [1, 2, 3.0]}), catalogname="xray") + Heasarc.get_datalinks(Table({"id": [1, 2, 3.0]}), catalog_name="xray") def test_download_data__empty(): diff --git a/astroquery/heasarc/tests/test_heasarc_remote.py b/astroquery/heasarc/tests/test_heasarc_remote.py index f2c7265de5..5a57d02579 100644 --- a/astroquery/heasarc/tests/test_heasarc_remote.py +++ b/astroquery/heasarc/tests/test_heasarc_remote.py @@ -79,7 +79,7 @@ def test_query_region_cone(self, coordinates): """ result = Heasarc.query_region( coordinates, - table="suzamaster", + catalog="suzamaster", spatial="cone", columns="*", radius=1 * u.arcmin, @@ -94,7 +94,7 @@ def test_query_columns_radius(self): Test selection of only a few columns, and using a bigger radius """ result = Heasarc.query_region( - "NGC 4151", table="suzamaster", columns="ra,dec,obsid", + "NGC 4151", catalog="suzamaster", columns="ra,dec,obsid", radius=10 * u.arcmin ) assert len(result) == 4 @@ -104,7 +104,7 @@ def test_query_columns_radius(self): def test_query_region_box(self): result = Heasarc.query_region( "182d38m08.64s 39d24m21.06s", - table="suzamaster", + catalog="suzamaster", columns="*", spatial="box", width=2 * u.arcmin, @@ -116,7 +116,7 @@ def test_query_region_polygon(self): polygon = [(10.1, 10.1), (10.0, 10.1), (10.0, 10.0)] with pytest.warns(Warning) as warnings: result = Heasarc.query_region( - table="suzamaster", spatial="polygon", polygon=polygon + catalog="suzamaster", spatial="polygon", polygon=polygon ) assert warnings[0].category == UserWarning assert ("Polygon endpoints are being interpreted" in @@ -124,32 +124,32 @@ def test_query_region_polygon(self): assert warnings[1].category == NoResultsWarning assert isinstance(result, Table) - def test_list_tables(self): - tables = Heasarc.tables() - # Number of available tables may change over time, test only for - # significant drop. (at the time of writing there are 1020 tables + def test_list_catalogs(self): + catalogs = Heasarc.list_catalogs() + # Number of available catalogs may change over time, test only for + # significant drop. (at the time of writing there are 1020 catalogs # in the list). - assert len(tables) > 1000 + assert len(catalogs) > 1000 - def test_list_tables__master(self): - tables = list(Heasarc.tables(master=True)["name"]) - assert "numaster" in tables - assert "nicermastr" in tables - assert "xmmmaster" in tables - assert "swiftmastr" in tables + def test_list_catalogs__master(self): + catalogs = list(Heasarc.catalogs(master=True)["name"]) + assert "numaster" in catalogs + assert "nicermastr" in catalogs + assert "xmmmaster" in catalogs + assert "swiftmastr" in tablcatalogses - def test_list_tables__keywords(self): - tables = list(Heasarc.tables(keywords="nustar", master=True)["name"]) - assert len(tables) == 1 and "numaster" in tables + def test_list_catalogs__keywords(self): + catalogs = list(Heasarc.list_catalogs(keywords="nustar", master=True)["name"]) + assert len(catalogs) == 1 and "numaster" in catalogs - tables = list(Heasarc.tables(keywords="xmm", master=True)["name"]) - assert len(tables) == 1 and "xmmmaster" in tables + catalogs = list(Heasarc.list_catalogs(keywords="xmm", master=True)["name"]) + assert len(catalogs) == 1 and "xmmmaster" in catalogs - tables = list(Heasarc.tables(keywords=["swift", "rosat"], + catalogs = list(Heasarc.list_catalogs(keywords=["swift", "rosat"], master=True)["name"]) - assert "swiftmastr" in tables - assert "rosmaster" in tables - assert "rassmaster" in tables + assert "swiftmastr" in catalogs + assert "rosmaster" in catalogs + assert "rassmaster" in catalogs @pytest.mark.skipif( Version(pyvo.__version__) < Version('1.4'), @@ -169,19 +169,19 @@ def test_tap__maxrec(self): @pytest.mark.parametrize("tdefault", DEFAULT_COLS) def test__get_default_columns(self, tdefault): - table, tdef = tdefault - remote_default = list(Heasarc._get_default_columns(table)) + catalog, tdef = tdefault + remote_default = list(Heasarc._get_default_columns(catalog)) assert remote_default == tdef - def test_get_datalinks__wrongtable(self): - with pytest.raises(ValueError, match="Unknown table name:"): + def test_get_datalinks__wrongcatalog(self): + with pytest.raises(ValueError, match="Unknown catalog name:"): Heasarc.get_datalinks( - Table({"__row": [1, 2, 3.0]}), tablename="wrongtable" + Table({"__row": [1, 2, 3.0]}), catalog_name="wrongcatalog" ) def test_get_datalinks__xmmmaster(self): links = Heasarc.get_datalinks( - Table({"__row": [4154, 4155]}), tablename="xmmmaster" + Table({"__row": [4154, 4155]}), catalog_name="xmmmaster" ) assert len(links) == 2 assert "access_url" in links.colnames @@ -287,7 +287,7 @@ def test_custom_args(self): heasarc = Heasarc with pytest.warns(AstropyDeprecationWarning): - table = heasarc.query_object( + catalog = heasarc.query_object( object_name, mission=mission, radius="1 degree", @@ -296,7 +296,7 @@ def test_custom_args(self): good_isgri=">1000", cache=False, ) - assert len(table) > 0 + assert len(catalog) > 0 def test_basic_example(self): mission = "rosmaster" @@ -304,9 +304,9 @@ def test_basic_example(self): heasarc = Heasarc with pytest.warns(AstropyDeprecationWarning): - table = heasarc.query_object(object_name, mission=mission) + catalog = heasarc.query_object(object_name, mission=mission) - assert len(table) == 63 + assert len(catalog) == 63 def test_mission_list(self): heasarc = Heasarc @@ -338,11 +338,11 @@ def test_query_region(self): skycoord_3C_273 = SkyCoord("12h29m06.70s +02d03m08.7s", frame="icrs") with pytest.warns(AstropyDeprecationWarning): - table = heasarc.query_region( + catalog = heasarc.query_region( skycoord_3C_273, mission=mission, radius="1 degree" ) - assert len(table) == 63 + assert len(catalog) == 63 def test_query_region_nohits(self): """ @@ -354,11 +354,11 @@ def test_query_region_nohits(self): # This was an example coordinate that returned nothing # Since Fermi is still active, it is possible that sometime in the # future an event will occur here. - table = heasarc.query_region( + catalog = heasarc.query_region( SkyCoord(0.28136 * u.deg, -0.09789 * u.deg, frame="fk5"), mission="hitomaster", radius=0.1 * u.deg, ) assert warnings[0].category == AstropyDeprecationWarning assert warnings[1].category == NoResultsWarning - assert len(table) == 0 + assert len(catalog) == 0