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

ICRSCoord tag implementation is moving to astropy #401

Merged
merged 10 commits into from
Dec 8, 2017
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

- Astropy-specific tags have moved to Astropy core package. [#359]

- ICRSCoord tag has moved to Astropy core package. [#401]

1.4.0 (unreleased)
------------------

Expand Down
2 changes: 1 addition & 1 deletion asdf-standard
3 changes: 0 additions & 3 deletions asdf/tags/wcs/tests/test_wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ def test_frames(tmpdir):
helpers.assert_roundtrip_tree(tree, tmpdir)


@pytest.mark.skipif(astropy.__version__ <= '1.3.3',
reason="It does not make sense to test backwards compatibility when using "
"earlier versions of astropy")
def test_backwards_compat_galcen():
# Hold these fields constant so that we can compare them
declination = 1.0208 # in degrees
Expand Down
17 changes: 14 additions & 3 deletions asdf/tags/wcs/wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class WCSType(AsdfType):
name = "wcs/wcs"
requires = _REQUIRES
types = ['gwcs.WCS']
version = '1.2.0'

@classmethod
def from_tree(cls, node, ctx):
Expand Down Expand Up @@ -65,13 +66,14 @@ def assert_equal(cls, old, new):
class StepType(dict, AsdfType):
name = "wcs/step"
requires = _REQUIRES
version = '1.2.0'


class FrameType(AsdfType):
name = "wcs/frame"
version = '1.1.0'
requires = ['gwcs', 'astropy-1.3.3']
types = ['gwcs.Frame2D']
version = '1.2.0'

import astropy
_astropy_version = astropy.__version__
Expand Down Expand Up @@ -269,7 +271,7 @@ def to_tree(cls, frame, ctx):
class CelestialFrameType(FrameType):
name = "wcs/celestial_frame"
types = ['gwcs.CelestialFrame']
supported_versions = [(1,0,0), (1,1,0)]
supported_versions = [(1,0,0), (1,1,0), (1,2,0)]

@classmethod
def from_tree(cls, node, ctx):
Expand Down Expand Up @@ -318,6 +320,7 @@ def to_tree(cls, frame, ctx):
class CompositeFrame(FrameType):
name = "wcs/composite_frame"
types = ['gwcs.CompositeFrame']
version = '1.1.0'

@classmethod
def from_tree(cls, node, ctx):
Expand Down Expand Up @@ -347,6 +350,10 @@ def assert_equal(cls, old, new):
helpers.assert_tree_match(old_frame, new_frame)

class ICRSCoord(AsdfType):
"""The newest version of this tag and the associated schema have moved to
Astropy. This implementation is retained here for the purposes of backwards
compatibility with older files.
"""
name = "wcs/icrs_coord"
types = ['astropy.coordinates.ICRS']
requires = ['astropy']
Expand All @@ -368,7 +375,11 @@ def from_tree(cls, node, ctx):
return ICRS(ra=ra, dec=dec)

@classmethod
def to_tree(cls, frame, ctx):
def to_tree(cls, frame, ctx): # pragma: no cover
# We do not run coverage analysis since new ICRS objects will be
# serialized by the tag implementation in Astropy. Eventually if we
# have a better way to write older versions of tags, we can re-add
# tests for this code.
from astropy.units import Quantity
from astropy.coordinates import ICRS
from astropy.io.misc.asdf.tags.unit.quantity import QuantityType
Expand Down
12 changes: 10 additions & 2 deletions asdf/tests/test_asdf_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,16 @@ def create_schema_example_id(argval):
generate_example_schemas(),
ids=create_schema_example_id)

@pytest.fixture(scope='module')
def asdf_resolver():
"""Using the resolver of an actual AsdfFile context instead of the default
resolver allows any extensions that were installed as entry points to be
used during the schema validation process.
"""
ctx = asdf.AsdfFile()
return ctx.resolver

def test_validate_schema(schema_path):
def test_validate_schema(schema_path, asdf_resolver):
"""Pytest to check validity of schema file at given path

Parameters:
Expand All @@ -177,7 +185,7 @@ def test_validate_schema(schema_path):
'parametrize' utility in order to account for all schema files.
"""
# Make sure that each schema itself is valid.
schema_tree = schema.load_schema(schema_path, resolve_references=True)
schema_tree = schema.load_schema(schema_path, resolver=asdf_resolver, resolve_references=True)
schema.check_schema(schema_tree)


Expand Down
5 changes: 3 additions & 2 deletions asdf/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,13 @@ def __hash__(self):
return super(AsdfSpec, self).__hash__()


default_version = AsdfVersion('1.1.0')
default_version = AsdfVersion('1.2.0')


supported_versions = [
AsdfVersion('1.0.0'),
AsdfVersion('1.1.0')
AsdfVersion('1.1.0'),
AsdfVersion('1.2.0')
]


Expand Down