Skip to content

Commit

Permalink
Merge pull request #219 from braingram/split_core
Browse files Browse the repository at this point in the history
Update for ASDF standard 1.6.0
  • Loading branch information
braingram committed Mar 10, 2024
2 parents 448542b + 34a791d commit 050ef58
Show file tree
Hide file tree
Showing 27 changed files with 582 additions and 117 deletions.
22 changes: 3 additions & 19 deletions .github/workflows/ci.yml
Expand Up @@ -38,7 +38,7 @@ jobs:
default_python: '3.9'
envs: |
- linux: py39-parallel-cov
- linux: py39-test-devdeps-parallel-cov
- linux: py311-test-devdeps-parallel-cov
- linux: py39-astropylts-parallel-cov
- linux: py39-transformlts-parallel-cov
coverage: codecov
Expand Down Expand Up @@ -71,6 +71,7 @@ jobs:
envs: |
- linux: py310-test-parallel
- linux: py311-test-parallel
- linux: py312-test-parallel
- macos: py311-test-parallel
- windows: py311-test-parallel
Expand All @@ -87,6 +88,7 @@ jobs:
envs: |
- linux: py310-test-devdeps-parallel
- linux: py311-test-devdeps-parallel
- linux: py311-test-devdeps-numpydev-parallel
oldest:
needs: [core, asdf-schemas]
Expand All @@ -102,24 +104,6 @@ jobs:
- linux: py39-test-oldestdep-parallels-cov
coverage: codecov

numpy:
needs: [core, asdf-schemas]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
cache-path: ~/.cache/pip
cache-key: pip-${{ needs.setup.outputs.requirements-hash }}
cache-restore-keys: |
pip-
# Any env name which does not start with `pyXY` will use this Python version.
default_python: '3.9'
envs: |
- linux: py39-test-numpy119-parallel
- linux: py39-test-numpy120-parallel
- linux: py310-test-numpy121-parallel
- linux: py310-test-numpy122-parallel
- linux: py311-test-numpy123-parallel
- linux: py311-test-numpy124-parallel
wheel_building:
permissions:
contents: none
Expand Down
9 changes: 9 additions & 0 deletions CHANGES.rst
@@ -1,3 +1,12 @@
0.6.0 (unreleased)
------------------

- Add python 3.12 support. [#219]
- Update ASDF standard 1.6.0 support. [#219]
- Increase minimum versions for ``asdf-coordinates-schemas``
``asdf-transform-schemas`` and list ``asdf-standard`` as
a dependency. [#219]

0.5.0 (2023-11-15)
------------------

Expand Down
40 changes: 0 additions & 40 deletions asdf_astropy/_manifest.py

This file was deleted.

2 changes: 1 addition & 1 deletion asdf_astropy/converters/coordinates/tests/test_frame.py
Expand Up @@ -115,7 +115,7 @@ def test_legacy_icrs_deseialize():
unit: deg"""
truth = ICRS(ra=Longitude(25, unit=u.deg), dec=Latitude(45, unit=u.deg))

buff = yaml_to_asdf(f"example: {example.strip()}")
buff = yaml_to_asdf(f"example: {example.strip()}", version="1.5.0")
with asdf.AsdfFile() as af:
af._open_impl(af, buff, mode="rw")
assert_frame_equal(af["example"], truth)
2 changes: 1 addition & 1 deletion asdf_astropy/converters/fits/tests/test_fits.py
Expand Up @@ -83,7 +83,7 @@ def test_asdf_tag():
- [BUNIT, DN, Units of the error array]
"""

buff = yaml_to_asdf(yaml)
buff = yaml_to_asdf(yaml, version="1.5.0")
with asdf.open(buff) as af:
hdul = af["hdul"]
assert len(hdul) == 3 # noqa: PLR2004
Expand Down
10 changes: 8 additions & 2 deletions asdf_astropy/converters/table/table.py
Expand Up @@ -3,7 +3,10 @@


class ColumnConverter(Converter):
tags = ("tag:stsci.edu:asdf/core/column-*",)
tags = (
"tag:stsci.edu:asdf/core/column-*",
"tag:stsci.edu:asdf/table/column-*",
)
types = (
"astropy.table.column.Column",
"astropy.table.column.MaskedColumn",
Expand Down Expand Up @@ -45,7 +48,10 @@ def from_yaml_tree(self, node, tag, ctx):


class AsdfTableConverter(Converter):
tags = ("tag:stsci.edu:asdf/core/table-*",)
tags = (
"tag:stsci.edu:asdf/core/table-*",
"tag:stsci.edu:asdf/table/table-*",
)
types = ()

def to_yaml_tree(self, obj, tag, ctx):
Expand Down
4 changes: 2 additions & 2 deletions asdf_astropy/converters/table/tests/test_table.py
Expand Up @@ -139,7 +139,7 @@ def test_mismatched_columns():
colnames: [a, b]
"""

buff = yaml_to_asdf(yaml)
buff = yaml_to_asdf(yaml, version="1.5.0")

with pytest.raises(ValueError, match="Inconsistent data column lengths"), asdf.open(buff):
pass
Expand Down Expand Up @@ -251,7 +251,7 @@ def test_asdf_table():
description: The target name
name: c
"""
buff = yaml_to_asdf(yaml)
buff = yaml_to_asdf(yaml, version="1.5.0")

with asdf.open(buff) as af:
table = af["table"]
Expand Down
6 changes: 5 additions & 1 deletion asdf_astropy/converters/time/tests/test_time.py
Expand Up @@ -111,7 +111,7 @@ def create_examples():

@pytest.mark.parametrize("example", create_examples())
def test_read_examples(example):
buff = yaml_to_asdf(f"example: {example['example'].strip()}")
buff = yaml_to_asdf(f"example: {example['example'].strip()}", version="1.5.0")
with asdf.AsdfFile() as af:
af._open_impl(af, buff, mode="rw")
assert np.all(af["example"] == example["truth"])
Expand All @@ -133,6 +133,10 @@ def create_formats():

formats = []
for format_ in TIME_FORMATS:
if format_ == "stardate":
# stardate is not a documented format for astropy
# https://docs.astropy.org/en/latest/time/index.html#time-format
continue
new = Time("B2000.0")
new.format = format_
formats.append(new)
Expand Down
4 changes: 2 additions & 2 deletions asdf_astropy/converters/transform/properties.py
Expand Up @@ -3,7 +3,7 @@


class ModelBoundingBoxConverter(Converter):
tags = ("tag:stsci.edu:asdf/transform/property/bounding_box-1.0.0",)
tags = ("tag:stsci.edu:asdf/transform/property/bounding_box-*",)
types = ("astropy.modeling.bounding_box.ModelBoundingBox",)

def to_yaml_tree(self, bbox, tag, ctx):
Expand Down Expand Up @@ -40,7 +40,7 @@ def create_bounding_box(model, cbbox=None):


class CompoundBoundingBoxConverter(Converter):
tags = ("tag:stsci.edu:asdf/transform/property/compound_bounding_box-1.0.0",)
tags = ("tag:stsci.edu:asdf/transform/property/compound_bounding_box-*",)
types = ("astropy.modeling.bounding_box.CompoundBoundingBox",)

def to_yaml_tree(self, cbbox, tag, ctx):
Expand Down
1 change: 1 addition & 0 deletions asdf_astropy/converters/transform/tests/test_transform.py
Expand Up @@ -529,6 +529,7 @@ def test_all_models_supported(model):

def test_legacy_const(tmp_path):
with asdf.config_context() as config:
config.remove_extension("asdf://asdf-format.org/transform/extensions/transform-1.6.0")
config.remove_extension("asdf://asdf-format.org/transform/extensions/transform-1.5.0")

model = astropy_models.Const1D(amplitude=5.0)
Expand Down
6 changes: 3 additions & 3 deletions asdf_astropy/converters/unit/tests/test_quantity.py
Expand Up @@ -44,7 +44,7 @@ def test_read_untagged_unit():
value: {value}
unit: kpc
"""
buff = helpers.yaml_to_asdf(yaml)
buff = helpers.yaml_to_asdf(yaml, version="1.5.0")
with asdf.open(buff) as af:
assert af["quantity"].value == value
assert af["quantity"].unit.is_equivalent(units.kpc)
Expand All @@ -57,7 +57,7 @@ def test_read_tagged_unit():
value: {value}
unit: !unit/unit-1.0.0 kpc
"""
buff = helpers.yaml_to_asdf(yaml)
buff = helpers.yaml_to_asdf(yaml, version="1.5.0")
with asdf.open(buff) as af:
assert af["quantity"].value == value
assert af["quantity"].unit.is_equivalent(units.kpc)
Expand All @@ -69,7 +69,7 @@ def test_read_array_value():
value: !core/ndarray-1.0.0 [1.0, 2.0, 3.0, 4.0]
unit: km
"""
buff = helpers.yaml_to_asdf(yaml)
buff = helpers.yaml_to_asdf(yaml, version="1.5.0")
with asdf.open(buff) as af:
assert_array_equal(af["quantity"].value, np.array([1.0, 2.0, 3.0, 4.0]))
assert af["quantity"].unit.is_equivalent(units.km)
Expand Down
69 changes: 42 additions & 27 deletions asdf_astropy/extensions.py
Expand Up @@ -6,7 +6,6 @@
from asdf.extension import ManifestExtension
from astropy.utils import minversion

from ._manifest import CompoundManifestExtension
from .converters.coordinates.angle import AngleConverter, LatitudeConverter, LongitudeConverter
from .converters.coordinates.earth_location import EarthLocationConverter
from .converters.coordinates.frame import FrameConverter, LegacyICRSConverter
Expand Down Expand Up @@ -39,11 +38,12 @@
"TRANSFORM_EXTENSIONS",
"COORDINATES_CONVERTERS",
"ASTROPY_CONVERTERS",
"COORDINATES_EXTENSION",
"COORDINATES_EXTENSIONS",
"ASTROPY_EXTENSIONS",
"CORE_CONVERTERS",
"CORE_MANIFEST_URIS",
"CORE_EXTENSIONS",
"UNIT_EXTENSIONS",
]

TRANSFORM_CONVERTERS = [
Expand Down Expand Up @@ -399,6 +399,7 @@
# The order here is important; asdf will prefer to use extensions
# that occur earlier in the list.
TRANSFORM_MANIFEST_URIS = [
"asdf://asdf-format.org/transform/manifests/transform-1.6.0",
"asdf://asdf-format.org/transform/manifests/transform-1.5.0",
"asdf://asdf-format.org/transform/manifests/transform-1.4.0",
"asdf://asdf-format.org/transform/manifests/transform-1.3.0",
Expand All @@ -407,7 +408,6 @@
"asdf://asdf-format.org/transform/manifests/transform-1.0.0",
]


TRANSFORM_EXTENSIONS = [
ManifestExtension.from_uri(
uri,
Expand Down Expand Up @@ -484,14 +484,22 @@
NdarrayMixinConverter(),
]


COORDINATES_EXTENSION = ManifestExtension.from_uri(
_COORDINATES_MANIFEST_URIS = [
"asdf://asdf-format.org/astronomy/coordinates/manifests/coordinates-1.1.0",
"asdf://asdf-format.org/astronomy/coordinates/manifests/coordinates-1.0.0",
converters=COORDINATES_CONVERTERS,
)
]

COORDINATES_EXTENSIONS = [
ManifestExtension.from_uri(
manifest_uri,
converters=COORDINATES_CONVERTERS,
)
for manifest_uri in _COORDINATES_MANIFEST_URIS
]


_ASTROPY_EXTENSION_MANIFEST_URIS = [
"asdf://astropy.org/astropy/manifests/astropy-1.2.0",
"asdf://astropy.org/astropy/manifests/astropy-1.1.0",
"asdf://astropy.org/astropy/manifests/astropy-1.0.0",
]
Expand All @@ -508,42 +516,49 @@
for manifest_uri in _ASTROPY_EXTENSION_MANIFEST_URIS
]


# These tags are part of the ASDF Standard,
# but we want to override serialization here so that users can
# work with nice astropy objects for those entities.
_FITS_CONVERTERS = [
AsdfFitsConverter(),
]

CORE_CONVERTERS = [
QuantityConverter(),
_TIME_CONVERTERS = [
TimeConverter(),
]

_TABLE_CONVERTERS = [
ColumnConverter(),
AsdfTableConverter(),
AsdfFitsConverter(),
]

UNIT_CONVETERS = [
_UNIT_CONVERTERS = [
UnitConverter(),
EquivalencyConverter(),
MagUnitConverter(),
QuantityConverter(),
]

CORE_CONVERTERS = _FITS_CONVERTERS + _TIME_CONVERTERS + _TABLE_CONVERTERS + _UNIT_CONVERTERS

UNIT_EXTENSIONS = [
ManifestExtension.from_uri(
"asdf://astropy.org/astropy/manifests/units-1.0.0",
converters=_UNIT_CONVERTERS,
),
]

# up to asdf 1.5.0 many tags supported by asdf-astropy
# were defined in core manifests
CORE_MANIFEST_URIS = [
"asdf://asdf-format.org/core/manifests/core-1.0.0",
"asdf://asdf-format.org/core/manifests/core-1.1.0",
"asdf://asdf-format.org/core/manifests/core-1.2.0",
"asdf://asdf-format.org/core/manifests/core-1.3.0",
"asdf://asdf-format.org/core/manifests/core-1.4.0",
"asdf://asdf-format.org/astronomy/manifests/astronomy-1.0.0",
"asdf://asdf-format.org/core/manifests/core-1.5.0",
"asdf://asdf-format.org/core/manifests/core-1.6.0",
"asdf://asdf-format.org/core/manifests/core-1.4.0",
"asdf://asdf-format.org/core/manifests/core-1.3.0",
"asdf://asdf-format.org/core/manifests/core-1.2.0",
"asdf://asdf-format.org/core/manifests/core-1.1.0",
"asdf://asdf-format.org/core/manifests/core-1.0.0",
]


CORE_EXTENSIONS = [
CompoundManifestExtension(
[
ManifestExtension.from_uri(u, converters=CORE_CONVERTERS),
ManifestExtension.from_uri("asdf://astropy.org/astropy/manifests/units-1.0.0", converters=UNIT_CONVETERS),
],
)
for u in CORE_MANIFEST_URIS
]
CORE_EXTENSIONS = [ManifestExtension.from_uri(u, converters=CORE_CONVERTERS) for u in CORE_MANIFEST_URIS]
3 changes: 2 additions & 1 deletion asdf_astropy/integration.py
Expand Up @@ -37,7 +37,8 @@ def get_extensions():

return [
*extensions.ASTROPY_EXTENSIONS,
extensions.COORDINATES_EXTENSION,
*extensions.COORDINATES_EXTENSIONS,
*extensions.TRANSFORM_EXTENSIONS,
*extensions.UNIT_EXTENSIONS,
*extensions.CORE_EXTENSIONS,
]

0 comments on commit 050ef58

Please sign in to comment.