Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix asdf extension url mapping bug #500

Merged
merged 2 commits into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,19 @@ matrix:

# Do a PEP8 test with pycodestyle
- os: linux
env: MAIN_CMD='pycodestyle specutils --count' SETUP_CMD=''
env: MAIN_CMD='pycodestyle specutils --count'
SETUP_CMD=''

# Try development version of Astropy
- os: linux
env: ASTROPY_VERSION=dev "PIP_DEPENDENCIES=$GWCS_DEV $ASDF_DEV"
env: ASTROPY_VERSION=dev
PIP_DEPENDENCIES="$GWCS_DEV $ASDF_DEV scipy matplotlib"

allow_failures:
# Try development version of Astropy
- os: linux
env: ASTROPY_VERSION=dev "PIP_DEPENDENCIES=$GWCS_DEV $ASDF_DEV"
env: ASTROPY_VERSION=dev
PIP_DEPENDENCIES="$GWCS_DEV $ASDF_DEV scipy matplotlib"


install:
Expand Down
10 changes: 10 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from importlib.util import find_spec
import pkg_resources

entry_points = []
for entry_point in pkg_resources.iter_entry_points('pytest11'):
entry_points.append(entry_point.name)

if "asdf_schema_tester" not in entry_points and find_spec('asdf') is not None:
pytest_plugins = ['asdf.tests.schema_tester']

2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,3 @@ github_project = astropy/specutils
install_requires = astropy>=3.1, gwcs, scipy
# version should be PEP440 compatible (http://www.python.org/dev/peps/pep-0440)
version = 0.6.dev

[entry_points]
1 change: 0 additions & 1 deletion specutils/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

# Use ASDF schema tester plugin if ASDF is installed
if find_spec('asdf') is not None:
pytest_plugins = ['asdf.tests.schema_tester']
PYTEST_HEADER_MODULES['Asdf'] = 'asdf'

# Uncomment the following lines to display the version number of the
Expand Down
5 changes: 3 additions & 2 deletions specutils/io/asdf/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Defines extension that is used by ASDF for recognizing specutils types
"""
import os
import urllib

from asdf.util import filepath_to_url
from asdf.extension import AsdfExtension
Expand All @@ -15,9 +16,9 @@
SCHEMA_PATH = os.path.abspath(
os.path.join(os.path.dirname(__file__), 'schemas'))
SPECUTILS_URL_MAPPING = [
(ASTROPY_SCHEMA_URI_BASE,
(urllib.parse.urljoin(ASTROPY_SCHEMA_URI_BASE, 'specutils/'),
filepath_to_url(
os.path.join(SCHEMA_PATH, 'astropy.org')) +
os.path.join(SCHEMA_PATH, 'astropy.org', 'specutils')) +
'/{url_suffix}.yaml')]


Expand Down
10 changes: 10 additions & 0 deletions specutils/io/asdf/tags/tests/test_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import numpy as np

import astropy.units as u
from astropy.coordinates import FK5

from asdf.tests.helpers import assert_roundtrip_tree
import asdf

from specutils import Spectrum1D, SpectrumList

Expand Down Expand Up @@ -46,3 +48,11 @@ def test_asdf_spectrumlist(tmpdir):

tree = dict(spectra=spectra)
assert_roundtrip_tree(tree, tmpdir)


@pytest.mark.filterwarnings("error::UserWarning")
def test_asdf_url_mapper():
"""Make sure specutils asdf extension url_mapping doesn't interfere with astropy schemas"""
frame = FK5()
af = asdf.AsdfFile()
af.tree = {'frame': frame}
2 changes: 1 addition & 1 deletion specutils/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This module tests SpecUtils io routines
"""

from ..io.parsing_utils import generic_spectrum_from_table # or something like that
from specutils.io.parsing_utils import generic_spectrum_from_table # or something like that
from astropy.io import registry
from astropy.table import Table
from astropy.utils.exceptions import AstropyUserWarning
Expand Down