From 3799997d5b48f32b3322d848deecdfcc8da1059a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Tue, 31 May 2022 14:03:45 -0700 Subject: [PATCH 1/8] Remove fixed xfails from OAC tests --- astroquery/oac/tests/test_oac_remote.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/astroquery/oac/tests/test_oac_remote.py b/astroquery/oac/tests/test_oac_remote.py index 3980547068..e14567900a 100644 --- a/astroquery/oac/tests/test_oac_remote.py +++ b/astroquery/oac/tests/test_oac_remote.py @@ -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") From 251c16e19f998da1066471fa26922dda3dcc3d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Tue, 31 May 2022 19:41:33 -0700 Subject: [PATCH 2/8] Fix bug in parsing text containing html tag --- astroquery/oac/core.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/astroquery/oac/core.py b/astroquery/oac/core.py index 28148b4166..84286dd9dd 100644 --- a/astroquery/oac/core.py +++ b/astroquery/oac/core.py @@ -12,6 +12,7 @@ import json import csv +import re import astropy.units as u from astropy.table import Column, Table @@ -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:] From e8acce332b26de22be867d3d1b2e7e5bf555c36f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Tue, 31 May 2022 19:42:51 -0700 Subject: [PATCH 3/8] Adding changelog --- CHANGES.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 9d5bb24dc0..5838b15455 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -38,6 +38,13 @@ linelists.cdms - Fix issues with the line name parser and the line data parser; the original implementation was incomplete and upstream was not fully documented. [#2385, #2411] +oac +^^^ + +- Fix bug in parsing events that contain html tags (e.g. in their alias + field). [#2423] + + Infrastructure, Utility and Other Changes and Additions ------------------------------------------------------- From c8ffd1ad38e41aaaf4a3c11f8934d3d0f37ab750 Mon Sep 17 00:00:00 2001 From: James Dempsey Date: Thu, 2 Jun 2022 09:20:46 +1000 Subject: [PATCH 4/8] Add version information for casda features --- docs/casda/casda.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/casda/casda.rst b/docs/casda/casda.rst index bf9ae9c7ac..b13c6ee1dc 100644 --- a/docs/casda/casda.rst +++ b/docs/casda/casda.rst @@ -80,10 +80,16 @@ from the keyring, or if in an interactive environment then it will be requested. >>> casda = Casda() >>> casda.login(username='email@somewhere.edu.au') +.. 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. @@ -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 From c194d8665cdb7b499ae6cdc9b751950c6d2aa38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sipo=CC=8Bcz?= Date: Wed, 1 Jun 2022 15:40:54 -0700 Subject: [PATCH 5/8] Adding online option to tox and the usage of pytest-rerunfailures for CI [skip ci] --- .github/workflows/ci_crontests.yml | 4 ++-- tox.ini | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci_crontests.yml b/.github/workflows/ci_crontests.yml index d8e29a32e5..9ca46787ba 100644 --- a/.github/workflows/ci_crontests.yml +++ b/.github/workflows/ci_crontests.yml @@ -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 diff --git a/tox.ini b/tox.ini index e71f963383..a4f2fd5321 100644 --- a/tox.ini +++ b/tox.ini @@ -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 = @@ -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 @@ -38,6 +42,7 @@ deps = oldestdeps: matplotlib==3.3.* oldestdeps: pyvo==1.1 cov: codecov + online: pytest-rerunfailures extras = test @@ -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 = From b39500fedcd51797794bec9aed292a647ef5bb70 Mon Sep 17 00:00:00 2001 From: Eero Vaher Date: Thu, 2 Jun 2022 22:46:43 +0200 Subject: [PATCH 6/8] Remove deprecated NASA Exoplanet Archive code The removed code was deprecated in v0.4.1 almost two years ago. --- .../nexsci/nasa_exoplanet_archive/core.py | 66 ------------------- .../tests/test_nasa_exoplanet_archive.py | 40 ----------- 2 files changed, 106 deletions(-) diff --git a/astroquery/ipac/nexsci/nasa_exoplanet_archive/core.py b/astroquery/ipac/nexsci/nasa_exoplanet_archive/core.py index 9f64b8e7b2..a02bd97927 100644 --- a/astroquery/ipac/nexsci/nasa_exoplanet_archive/core.py +++ b/astroquery/ipac/nexsci/nasa_exoplanet_archive/core.py @@ -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 @@ -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.""" @@ -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() diff --git a/astroquery/ipac/nexsci/nasa_exoplanet_archive/tests/test_nasa_exoplanet_archive.py b/astroquery/ipac/nexsci/nasa_exoplanet_archive/tests/test_nasa_exoplanet_archive.py index d240a0d5df..89bba99961 100644 --- a/astroquery/ipac/nexsci/nasa_exoplanet_archive/tests/test_nasa_exoplanet_archive.py +++ b/astroquery/ipac/nexsci/nasa_exoplanet_archive/tests/test_nasa_exoplanet_archive.py @@ -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() From f53f956ebd8b716d9d28d73784a8474edac0e52b Mon Sep 17 00:00:00 2001 From: Eero Vaher Date: Thu, 2 Jun 2022 22:51:34 +0200 Subject: [PATCH 7/8] Add change log entry for #2431 --- CHANGES.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 9d5bb24dc0..973cd1179a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -26,6 +26,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 ^^^^^^^ From 7c018482036083b385956946cd408194fa4aa77e Mon Sep 17 00:00:00 2001 From: Eero Vaher Date: Mon, 6 Jun 2022 14:57:15 +0200 Subject: [PATCH 8/8] Remove last `from __future__` imports The removed imports had no effect in Python 3. --- astroquery/esa/iso/tests/setup_package.py | 2 -- astroquery/exoplanet_orbit_database/__init__.py | 2 -- .../exoplanet_orbit_database/exoplanet_orbit_database.py | 2 -- .../tests/test_exoplanet_orbit_database.py | 2 -- astroquery/query.py | 2 -- astroquery/sdss/core.py | 2 -- astroquery/sdss/field_names.py | 3 --- 7 files changed, 15 deletions(-) diff --git a/astroquery/esa/iso/tests/setup_package.py b/astroquery/esa/iso/tests/setup_package.py index d7fbb63889..5bd0d2336f 100644 --- a/astroquery/esa/iso/tests/setup_package.py +++ b/astroquery/esa/iso/tests/setup_package.py @@ -9,8 +9,6 @@ """ -from __future__ import absolute_import - import os diff --git a/astroquery/exoplanet_orbit_database/__init__.py b/astroquery/exoplanet_orbit_database/__init__.py index 10bf83d322..4c67c342e1 100644 --- a/astroquery/exoplanet_orbit_database/__init__.py +++ b/astroquery/exoplanet_orbit_database/__init__.py @@ -5,8 +5,6 @@ :Author: Brett M. Morris (brettmorris21@gmail.com) """ -from __future__ import (absolute_import, division, print_function, - unicode_literals) from .exoplanet_orbit_database import (ExoplanetOrbitDatabase, ExoplanetOrbitDatabaseClass) from astropy import config as _config diff --git a/astroquery/exoplanet_orbit_database/exoplanet_orbit_database.py b/astroquery/exoplanet_orbit_database/exoplanet_orbit_database.py index acd0776473..2ea35bcb42 100644 --- a/astroquery/exoplanet_orbit_database/exoplanet_orbit_database.py +++ b/astroquery/exoplanet_orbit_database/exoplanet_orbit_database.py @@ -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 diff --git a/astroquery/exoplanet_orbit_database/tests/test_exoplanet_orbit_database.py b/astroquery/exoplanet_orbit_database/tests/test_exoplanet_orbit_database.py index af4e9c3847..e1f7343b6c 100644 --- a/astroquery/exoplanet_orbit_database/tests/test_exoplanet_orbit_database.py +++ b/astroquery/exoplanet_orbit_database/tests/test_exoplanet_orbit_database.py @@ -1,5 +1,3 @@ -from __future__ import (absolute_import, division, print_function, - unicode_literals) import os import pytest diff --git a/astroquery/query.py b/astroquery/query.py index b8cd1bc9c5..15f4149123 100644 --- a/astroquery/query.py +++ b/astroquery/query.py @@ -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 diff --git a/astroquery/sdss/core.py b/astroquery/sdss/core.py index 975e919ee1..de0e91e451 100644 --- a/astroquery/sdss/core.py +++ b/astroquery/sdss/core.py @@ -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 diff --git a/astroquery/sdss/field_names.py b/astroquery/sdss/field_names.py index caa2ff9fc7..53d417652e 100644 --- a/astroquery/sdss/field_names.py +++ b/astroquery/sdss/field_names.py @@ -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