Skip to content

Commit

Permalink
Merge pull request #2861 from bsipocz/DEP_Table_vs_TableElement
Browse files Browse the repository at this point in the history
DEP: votable.tree.Table was renamed to TableElement
  • Loading branch information
bsipocz committed Oct 24, 2023
2 parents ff01bc1 + 8dc8274 commit 59cc72b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 21 deletions.
27 changes: 16 additions & 11 deletions astroquery/cadc/tests/test_cadctap.py
Expand Up @@ -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 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, 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
Expand Down Expand Up @@ -83,10 +88,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()
Expand Down Expand Up @@ -367,7 +372,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="*"),
Expand Down
8 changes: 4 additions & 4 deletions astroquery/vo_conesearch/conesearch.py
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
"""
Expand Down
4 changes: 2 additions & 2 deletions astroquery/vo_conesearch/core.py
Expand Up @@ -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
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions astroquery/vo_conesearch/vos_catalog.py
Expand Up @@ -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
------
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion docs/conf.py
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion docs/vo_conesearch/client.rst
Expand Up @@ -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
Expand Down

0 comments on commit 59cc72b

Please sign in to comment.