Skip to content

Commit

Permalink
Merge pull request #95 from astrofrog/parser-api-compat
Browse files Browse the repository at this point in the history
Fix compatibility with future glue-core changes
  • Loading branch information
astrofrog authored Aug 11, 2023
2 parents a4476e0 + a83efdc commit e895db9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 5 additions & 2 deletions glue_astronomy/io/spectral_cube/spectral_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)]
8 changes: 6 additions & 2 deletions glue_astronomy/io/spectral_cube/tests/test_spectral_cube.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ xfail_strict = true
filterwarnings =
error
ignore:numpy\.ndarray size changed:RuntimeWarning
ignore:`product` is deprecated

[flake8]
max-line-length = 100

0 comments on commit e895db9

Please sign in to comment.