From 518196638b02b70c560e42e81acd11a272acb48f Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Fri, 11 Aug 2023 09:55:01 +0100 Subject: [PATCH 1/2] Fix compatibility with future glue-core changes --- glue_astronomy/io/spectral_cube/spectral_cube.py | 7 +++++-- .../io/spectral_cube/tests/test_spectral_cube.py | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/glue_astronomy/io/spectral_cube/spectral_cube.py b/glue_astronomy/io/spectral_cube/spectral_cube.py index 02dcd13..a479f1f 100644 --- a/glue_astronomy/io/spectral_cube/spectral_cube.py +++ b/glue_astronomy/io/spectral_cube/spectral_cube.py @@ -3,7 +3,10 @@ from spectral_cube import SpectralCube, StokesSpectralCube from glue.core import Data -from glue.config import data_factory, qglue_parser +try: + from glue.config import data_factory, cli_parser +except ImportError: # older versions of glue-core + from glue.config import data_factory, qglue_parser as cli_parser from glue.core.data_factories.fits import is_fits from glue.core.coordinates import coordinates_from_wcs @@ -69,6 +72,6 @@ def read_spectral_cube(filename, **kwargs): return spectral_cube_to_data(cube) -@qglue_parser((SpectralCube, StokesSpectralCube)) +@cli_parser((SpectralCube, StokesSpectralCube)) def parse_spectral_cube(cube, label): return [spectral_cube_to_data(cube, label=label)] diff --git a/glue_astronomy/io/spectral_cube/tests/test_spectral_cube.py b/glue_astronomy/io/spectral_cube/tests/test_spectral_cube.py index 7239717..d767ca7 100644 --- a/glue_astronomy/io/spectral_cube/tests/test_spectral_cube.py +++ b/glue_astronomy/io/spectral_cube/tests/test_spectral_cube.py @@ -1,6 +1,10 @@ import numpy as np from astropy.utils.data import get_pkg_data_filename, get_pkg_data_path -from glue.qglue import parse_data +try: + from glue.core.parsers import parse_data +except ImportError: # older versions of glue-core + from glue.qglue import parse_data + from spectral_cube import SpectralCube from glue_astronomy.io.spectral_cube.spectral_cube import is_spectral_cube, read_spectral_cube @@ -42,7 +46,7 @@ def test_reader_casa(): assert data.shape == (2, 3, 4) -def test_qglue(): +def test_parse_data(): cube = SpectralCube.read(get_pkg_data_filename('data/cube_3d.fits')) data = parse_data(cube, 'x')[0] assert data.label == 'x' From a83efdc5d9177b1b92f6f4ffbd83edf6b77ec4ce Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Fri, 11 Aug 2023 12:28:55 +0100 Subject: [PATCH 2/2] Ignore casa-formats-io deprecation warning --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 53d297e..26d59f7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -55,6 +55,7 @@ xfail_strict = true filterwarnings = error ignore:numpy\.ndarray size changed:RuntimeWarning + ignore:`product` is deprecated [flake8] max-line-length = 100