Skip to content

Commit

Permalink
Merge branch 'main' into gaia-astroquery-1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsarmiento authored Jun 9, 2022
2 parents 083cc2f + 9526b6f commit d90083f
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 129 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci_crontests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
- name: Python 3.9 with all dependencies with remote data
os: ubuntu-latest
python: '3.9'
toxenv: py39-test-alldeps-devdeps
toxenv: py39-test-alldeps-devdeps-online
toxargs: -v
toxposargs: --remote-data -v --durations=50
toxposargs: -v --durations=50

- name: pre-repease dependencies with all dependencies
os: ubuntu-latest
Expand Down
11 changes: 11 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ casda
- Use the standard ``login`` method for authenticating, which supports the system
keyring [#2386]

ipac.nexsci.nasa_exoplanet_archive
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- The deprecated methods ``query_planet()`` and ``query_star()`` have been removed.

jplsbdb
^^^^^^^

Expand All @@ -53,6 +58,12 @@ gaia
With this change the epoch photometry service returns all data associated to
a given source. [#2376]

oac
^^^

- Fix bug in parsing events that contain html tags (e.g. in their alias
field). [#2423]

Infrastructure, Utility and Other Changes and Additions
-------------------------------------------------------

Expand Down
2 changes: 0 additions & 2 deletions astroquery/esa/iso/tests/setup_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"""

from __future__ import absolute_import

import os


Expand Down
2 changes: 0 additions & 2 deletions astroquery/exoplanet_orbit_database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
:Author: Brett M. Morris ([email protected])
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from .exoplanet_orbit_database import (ExoplanetOrbitDatabase,
ExoplanetOrbitDatabaseClass)
from astropy import config as _config
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import json
import os

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import os

import pytest
Expand Down
66 changes: 0 additions & 66 deletions astroquery/ipac/nexsci/nasa_exoplanet_archive/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from astropy.io import ascii
from astropy.io.votable import parse_single_table
from astropy.table import QTable
from astropy.utils import deprecated, deprecated_renamed_argument
from astropy.utils.exceptions import AstropyWarning

# Import astroquery utilities
Expand Down Expand Up @@ -629,25 +628,6 @@ def _parse_result(self, response, verbose=False):

return data

def _handle_all_columns_argument(self, **kwargs):
"""
Deal with the ``all_columns`` argument that was exposed by earlier versions
This method will warn users about this deprecated argument and update the query syntax
to use ``select='*'``.
"""
# We also have to manually pop these arguments from the dict because
# `deprecated_renamed_argument` doesn't do that for some reason for all supported astropy
# versions (v3.1 was beheaving as expected)
kwargs.pop("show_progress", None)
kwargs.pop("table_path", None)

# Deal with `all_columns` properly
if kwargs.pop("all_columns", None):
kwargs["select"] = kwargs.get("select", "*")

return kwargs

@class_or_instance
def _request_to_sql(self, request_payload):
"""Convert request_payload dict to SQL query string to be parsed by TAP."""
Expand Down Expand Up @@ -677,51 +657,5 @@ def _request_to_sql(self, request_payload):

return tap_query

@deprecated(since="v0.4.1", alternative="query_object")
@deprecated_renamed_argument(["show_progress", "table_path"],
[None, None], "v0.4.1", arg_in_kwargs=True)
def query_planet(self, planet_name, cache=None, **criteria):
"""
Search the ``exoplanets`` table for a confirmed planet
Parameters
----------
planet_name : str
The name of a confirmed planet. If ``regularize`` is ``True``, an attempt will be made
to regularize this name using the ``aliastable`` table.
cache : bool, optional
Should the request result be cached? This can be useful for large repeated queries,
but since the data in the archive is updated regularly, this defaults to ``False``.
**criteria
Any other filtering criteria to apply. Values provided using the ``where`` keyword will
be ignored.
"""
criteria = self._handle_all_columns_argument(**criteria)
criteria["where"] = "pl_name='{0}'".format(planet_name.strip())
return self.query_criteria("exoplanets", cache=cache, **criteria)

@deprecated(since="v0.4.1", alternative="query_object")
@deprecated_renamed_argument(["show_progress", "table_path"],
[None, None], "v0.4.1", arg_in_kwargs=True)
def query_star(self, host_name, cache=None, **criteria):
"""
Search the ``exoplanets`` table for a confirmed planet host
Parameters
----------
host_name : str
The name of a confirmed planet host. If ``regularize`` is ``True``, an attempt will be
made to regularize this name using the ``aliastable`` table.
cache : bool, optional
Should the request result be cached? This can be useful for large repeated queries,
but since the data in the archive is updated regularly, this defaults to ``False``.
**criteria
Any other filtering criteria to apply. Values provided using the ``where`` keyword will
be ignored.
"""
criteria = self._handle_all_columns_argument(**criteria)
criteria["where"] = "pl_hostname='{0}'".format(host_name.strip())
return self.query_criteria("exoplanets", cache=cache, **criteria)


NasaExoplanetArchive = NasaExoplanetArchiveClass()
Original file line number Diff line number Diff line change
Expand Up @@ -168,46 +168,6 @@ def test_get_access_url():
assert get_access_url('aliaslookup') == conf.url_aliaslookup


def test_backwards_compat(patch_get):
"""
These are the tests from the previous version of this interface.
They query old tables by default and should return InvalidTableError.
"""
NasaExoplanetArchiveMock = NasaExoplanetArchiveClass()

NasaExoplanetArchiveMock._tap_tables = ['list']

# test_hd209458b_exoplanets_archive
with pytest.warns(AstropyDeprecationWarning):
with pytest.raises(InvalidTableError) as error:
NasaExoplanetArchiveMock.query_planet("HD 209458 b ")
assert "replaced" in str(error)

# test_hd209458b_exoplanet_archive_coords
with pytest.warns(AstropyDeprecationWarning):
with pytest.raises(InvalidTableError) as error:
NasaExoplanetArchiveMock.query_planet("HD 209458 b ")
assert "replaced" in str(error)

# test_hd209458_stellar_exoplanet
with pytest.warns(AstropyDeprecationWarning):
with pytest.raises(InvalidTableError) as error:
NasaExoplanetArchiveMock.query_star("HD 209458")
assert "replaced" in str(error)

# test_hd136352_stellar_exoplanet_archive
with pytest.warns(AstropyDeprecationWarning):
with pytest.raises(InvalidTableError) as error:
NasaExoplanetArchiveMock.query_star("HD 136352")
assert "replaced" in str(error)

# test_exoplanet_archive_query_all_columns
with pytest.warns(AstropyDeprecationWarning):
with pytest.raises(InvalidTableError) as error:
NasaExoplanetArchiveMock.query_planet("HD 209458 b ", all_columns=True)
assert "replaced" in str(error)


@pytest.mark.parametrize("table,query", API_TABLES)
def test_api_tables(patch_get, table, query):
NasaExoplanetArchiveMock = NasaExoplanetArchiveClass()
Expand Down
8 changes: 7 additions & 1 deletion astroquery/oac/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import json
import csv
import re

import astropy.units as u
from astropy.table import Column, Table
Expand Down Expand Up @@ -435,7 +436,12 @@ def _args_to_payload(self, event, quantity,

def _format_output(self, raw_output):
if self.FORMAT == 'csv':
split_output = raw_output.splitlines()

fixed_raw_output = re.sub('<[^<]+?>', '', raw_output)
split_output = fixed_raw_output.splitlines()

# Remove any HTML tags

columns = list(csv.reader([split_output[0]], delimiter=',',
quotechar='"'))[0]
rows = split_output[1:]
Expand Down
6 changes: 4 additions & 2 deletions astroquery/oac/tests/test_oac_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,27 @@ def test_query_region_box_json(self):
data_format='json')
assert isinstance(phot, dict)

@pytest.mark.xfail(reason="Upstream API issue. See #1130")
def test_get_photometry(self):
phot = OAC.get_photometry(event="SN2014J")
assert isinstance(phot, Table)
assert len(phot) > 0

def test_get_photometry_b(self):
phot = OAC.get_photometry(event="SN2014J")
assert isinstance(phot, Table)
assert len(phot) > 0

@pytest.mark.xfail(reason="Upstream API issue. See #1130")
def test_get_single_spectrum(self):
spec = OAC.get_single_spectrum(event="SN2014J",
time=self.test_time)
assert isinstance(spec, Table)
assert len(spec) > 0

def test_get_single_spectrum_b(self):
test_time = 56680
spec = OAC.get_single_spectrum(event="SN2014J", time=test_time)
assert isinstance(spec, Table)
assert len(spec) > 0

def test_get_spectra(self):
spec = OAC.get_spectra(event="SN2014J")
Expand Down
2 changes: 0 additions & 2 deletions astroquery/query.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import abc
import inspect
import pickle
Expand Down
2 changes: 0 additions & 2 deletions astroquery/sdss/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"""
Access Sloan Digital Sky Survey database online.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import io
import warnings
import numpy as np
Expand Down
3 changes: 0 additions & 3 deletions astroquery/sdss/field_names.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import json
import warnings

Expand Down
11 changes: 11 additions & 0 deletions docs/casda/casda.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,16 @@ from the keyring, or if in an interactive environment then it will be requested.
>>> casda = Casda()
>>> casda.login(username='[email protected]')

.. Note::

Prior to Astroquery v0.4.7, authentication required creating an instance of the ``Casda`` class
with a username and password. e.g.: ``casda = Casda(username, password)``

Data Access
===========

.. versionadded:: 0.4.4

In order to access data in CASDA you must first stage the data using the :meth:`~astroquery.casda.CasdaClass.stage_data`
method.
This is because only some of the data in CASDA is held on disc at any particular time.
Expand Down Expand Up @@ -111,10 +117,15 @@ taken in scheduling block 2338 is shown below:
>>> url_list = casda.stage_data(subset)
>>> filelist = casda.download_files(url_list, savedir='/tmp')

.. Note::

Due to server side changes, downloads now require Astroquery v0.4.6 or later.

Cutouts
=======

.. versionadded:: 0.4.7

As well as accessing full data products, the CASDA service can produce cutout images and cubes from larger data products.
The cutout support in AstroQuery allows both spatial and spectral cutouts.
To produce a spatial cutout, pass in a coordinate and either a radius or a height and a width to the
Expand Down
11 changes: 8 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py{37,38,39,310}-test{,-alldeps,-oldestdeps,-devdeps,-predeps}{,-cov}
py{37,38,39,310}-test{,-alldeps,-oldestdeps,-devdeps,-predeps}{,-online}{,-cov}
codestyle
build_docs
requires =
Expand All @@ -26,6 +26,10 @@ changedir = .tmp/{envname}

description = run tests

setenv =
PYTEST_ARGS = ''
online: PYTEST_ARGS = --remote-data=any --reruns=1 --reruns-delay 10

deps =
devdeps: git+https://github.com/astropy/astropy.git#egg=astropy
devdeps: git+https://github.com/astropy/pyvo.git#egg=pyvo
Expand All @@ -38,6 +42,7 @@ deps =
oldestdeps: matplotlib==3.3.*
oldestdeps: pyvo==1.1
cov: codecov
online: pytest-rerunfailures

extras =
test
Expand All @@ -47,8 +52,8 @@ extras =
commands =
pip freeze
# FIXME: there are too many failures in the docs example gallery, ignore it for now
!cov: pytest --pyargs astroquery {toxinidir}/docs --ignore={toxinidir}/docs/gallery* {posargs}
cov: pytest --pyargs astroquery {toxinidir}/docs --ignore={toxinidir}/docs/gallery* --cov astroquery --cov-config={toxinidir}/setup.cfg {posargs}
!cov: pytest --pyargs astroquery {toxinidir}/docs --ignore={toxinidir}/docs/gallery* {env:PYTEST_ARGS} {posargs}
cov: pytest --pyargs astroquery {toxinidir}/docs --ignore={toxinidir}/docs/gallery* --cov astroquery --cov-config={toxinidir}/setup.cfg {env:PYTEST_ARGS} {posargs}
cov: coverage xml -o {toxinidir}/coverage.xml

pip_pre =
Expand Down

0 comments on commit d90083f

Please sign in to comment.