From 2f4a41f04922080e92a773b0ed1d2d6ffb142625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Fri, 20 Oct 2023 13:14:24 -0700 Subject: [PATCH 1/3] DEP: votable.tree.Table was renamed to TableElement --- astroquery/cadc/tests/test_cadctap.py | 14 +++++++------- astroquery/vo_conesearch/conesearch.py | 8 ++++---- astroquery/vo_conesearch/core.py | 4 ++-- astroquery/vo_conesearch/vos_catalog.py | 4 ++-- docs/vo_conesearch/client.rst | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/astroquery/cadc/tests/test_cadctap.py b/astroquery/cadc/tests/test_cadctap.py index f0475996b9..0a16d74077 100644 --- a/astroquery/cadc/tests/test_cadctap.py +++ b/astroquery/cadc/tests/test_cadctap.py @@ -11,9 +11,9 @@ import os import sys -from astropy.table import Table as AstroTable +from astropy.table import Table from astropy.io.fits.hdu.hdulist import HDUList -from astropy.io.votable.tree import VOTableFile, Resource, Table, Field +from astropy.io.votable.tree import VOTableFile, Resource, TableElement, Field from astropy.io.votable import parse from astropy.utils.diff import report_diff_values from astroquery.utils.commons import parse_coordinates, FileContainer @@ -83,10 +83,10 @@ def mock_run_query(query, output_format=None, maxrec=None, assert output_format is None assert maxrec is None assert output_file is None - table = AstroTable(rows=[('CFHT', 'Optical'), ('CFHT', 'Infrared'), - ('JCMT', 'Millimeter'), ('DAO', 'Optical'), - ('DAO', 'Infrared')], - names=('collection', 'energy_emBand')) + table = Table(rows=[('CFHT', 'Optical'), ('CFHT', 'Infrared'), + ('JCMT', 'Millimeter'), ('DAO', 'Optical'), + ('DAO', 'Infrared')], + names=('collection', 'energy_emBand')) return table cadc.exec_sync = mock_run_query result = cadc.get_collections() @@ -367,7 +367,7 @@ def test_exec_sync(tmp_path): votable = VOTableFile() resource = Resource() votable.resources.append(resource) - table = Table(votable) + table = TableElement(votable) resource.tables.append(table) table.fields.extend([ Field(votable, name="filename", datatype="char", arraysize="*"), diff --git a/astroquery/vo_conesearch/conesearch.py b/astroquery/vo_conesearch/conesearch.py index 7430d4d01a..1d8e1acc59 100644 --- a/astroquery/vo_conesearch/conesearch.py +++ b/astroquery/vo_conesearch/conesearch.py @@ -175,7 +175,7 @@ def conesearch(center, radius, *, verb=1, catalog_db=None, return_astropy_table : bool Returned ``obj`` will be `astropy.table.Table` rather - than `astropy.io.votable.tree.Table`. + than `astropy.io.votable.tree.TableElement`. use_names_over_ids : bool When `True` use the ``name`` attributes of columns as the names @@ -186,7 +186,7 @@ def conesearch(center, radius, *, verb=1, catalog_db=None, Returns ------- - obj : `astropy.table.Table` or `astropy.io.votable.tree.Table` + obj : `astropy.table.Table` or `astropy.io.votable.tree.TableElement` First table from first successful VO service request. See ``return_astropy_table`` parameter for the kind of table returned. @@ -312,7 +312,7 @@ def search_all(*args, **kwargs): Returns ------- - result : dict of `astropy.io.votable.tree.Table` objects + result : dict of `astropy.io.votable.tree.TableElement` objects A dictionary of tables from successful VO service requests, with keys being the access URLs. If none is successful, an empty dictionary is returned. @@ -513,7 +513,7 @@ def conesearch_timer(*args, **kwargs): t : float Run time in seconds. - obj : `astropy.io.votable.tree.Table` + obj : `astropy.io.votable.tree.TableElement` First table from first successful VO service request. """ diff --git a/astroquery/vo_conesearch/core.py b/astroquery/vo_conesearch/core.py index a31c21eb93..584f98b7ac 100644 --- a/astroquery/vo_conesearch/core.py +++ b/astroquery/vo_conesearch/core.py @@ -121,7 +121,7 @@ def query_region(self, coordinates, radius, *, verb=1, return_astropy_table : bool Returned ``result`` will be `astropy.table.Table` rather - than `astropy.io.votable.tree.Table`. + than `astropy.io.votable.tree.TableElement`. use_names_over_ids : bool When `True` use the ``name`` attributes of columns as the names @@ -132,7 +132,7 @@ def query_region(self, coordinates, radius, *, verb=1, Returns ------- - result : `astropy.table.Table` or `astropy.io.votable.tree.Table` + result : `astropy.table.Table` or `astropy.io.votable.tree.TableElement` Table from successful VO service request. See ``return_astropy_table`` option for the kind of table returned. diff --git a/astroquery/vo_conesearch/vos_catalog.py b/astroquery/vo_conesearch/vos_catalog.py index b88f79b7a0..b67127aaf6 100644 --- a/astroquery/vo_conesearch/vos_catalog.py +++ b/astroquery/vo_conesearch/vos_catalog.py @@ -745,7 +745,7 @@ def vo_tab_parse(tab, url, kwargs): Returns ------- - out_tab : `astropy.io.votable.tree.Table` + out_tab : `astropy.io.votable.tree.TableElement` Raises ------ @@ -857,7 +857,7 @@ def call_vo_service(service_type, catalog_db=None, pedantic=None, Returns ------- - obj : `astropy.io.votable.tree.Table` + obj : `astropy.io.votable.tree.TableElement` First table from first successful VO service request. Raises diff --git a/docs/vo_conesearch/client.rst b/docs/vo_conesearch/client.rst index 7e953f6435..0cdc68f713 100644 --- a/docs/vo_conesearch/client.rst +++ b/docs/vo_conesearch/client.rst @@ -306,7 +306,7 @@ float64 bytes13 float64 float64 ... float64 float64 float64 Unlike :func:`~astroquery.vo_conesearch.conesearch.conesearch`, :func:`~astroquery.vo_conesearch.vos_catalog.call_vo_service` is a low-level -function and returns `astropy.io.votable.tree.Table`. To convert it to +function and returns `astropy.io.votable.tree.TableElement`. To convert it to `astropy.table.Table`: >>> tab = result.to_table() # doctest: +REMOTE_DATA From d65661fd165dc5fdf17a5de4e66c416c93eeacd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Tue, 24 Oct 2023 08:18:22 -0700 Subject: [PATCH 2/3] DEP: make import work with older astropy versions --- astroquery/cadc/tests/test_cadctap.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/astroquery/cadc/tests/test_cadctap.py b/astroquery/cadc/tests/test_cadctap.py index 0a16d74077..4e746f9be6 100644 --- a/astroquery/cadc/tests/test_cadctap.py +++ b/astroquery/cadc/tests/test_cadctap.py @@ -10,23 +10,28 @@ from pathlib import Path import os import sys +from unittest.mock import Mock, patch, PropertyMock +import pytest +import requests +import warnings from astropy.table import Table from astropy.io.fits.hdu.hdulist import HDUList -from astropy.io.votable.tree import VOTableFile, Resource, TableElement, Field +from astropy.io.votable.tree import VOTableFile, Resource, Field from astropy.io.votable import parse from astropy.utils.diff import report_diff_values from astroquery.utils.commons import parse_coordinates, FileContainer from astropy import units as u -import pytest -import requests -import warnings from pyvo.auth import securitymethods from astroquery.cadc import Cadc, conf import astroquery.cadc.core as cadc_core -from unittest.mock import Mock, patch, PropertyMock +try: + # Workaround astropy deprecation, remove try/except once >=6.0 is required + from astropy.io.votable.tree import TableElement +except ImportError: + from astropy.io.votable.tree import Table as TableElement try: # workaround for https://github.com/astropy/astroquery/issues/2523 to support bs4<4.11 From 8dc82740d3513a01d41e64399b80220a2c934100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Tue, 24 Oct 2023 08:36:01 -0700 Subject: [PATCH 3/3] TMP: use latest astropy for sphinx mapping until v6.0 is released --- docs/conf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 43ac74f87b..6d70fa6bdb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -64,8 +64,10 @@ del intersphinx_mapping['scipy'] del intersphinx_mapping['h5py'] + +# Using astropy latest in the mapping is temporary, change it back to stable once 6.0 is out intersphinx_mapping.update({ - 'astropy': ('https://docs.astropy.org/en/stable/', None), + 'astropy': ('https://docs.astropy.org/en/latest/', None), 'requests': ('https://requests.kennethreitz.org/en/stable/', None), 'regions': ('https://astropy-regions.readthedocs.io/en/stable/', None), 'mocpy': ('https://cds-astro.github.io/mocpy/', None),