Skip to content

Commit

Permalink
switch default asdf-standard to 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Mar 27, 2024
1 parent 48c5c57 commit 772c0e8
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 49 deletions.
3 changes: 2 additions & 1 deletion asdf/_tests/core/_converters/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def test_history_entry():
def test_subclass_metadata():
subclass_metadata = SubclassMetadata(name="SomeCoolSubclass")

result = helpers.roundtrip_object(subclass_metadata)
# support for this was dropped in 1.6.0
result = helpers.roundtrip_object(subclass_metadata, version="1.5.0")

assert result == subclass_metadata
56 changes: 28 additions & 28 deletions asdf/_tests/tags/core/tests/test_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class NDArrayContainerExtension:

def test_copy_inline():
yaml = """
x0: !core/ndarray-1.0.0
x0: !core/ndarray-1.1.0
data: [-1.0, 1.0]
"""

Expand Down Expand Up @@ -371,7 +371,7 @@ def test_inline():


def test_inline_bare():
content = "arr: !core/ndarray-1.0.0 [[1, 2, 3, 4], [5, 6, 7, 8]]"
content = "arr: !core/ndarray-1.1.0 [[1, 2, 3, 4], [5, 6, 7, 8]]"
buff = helpers.yaml_to_asdf(content)

with asdf.open(buff) as ff:
Expand Down Expand Up @@ -403,7 +403,7 @@ def test_len_roundtrip(tmp_path):

def test_mask_arbitrary():
content = """
arr: !core/ndarray-1.0.0
arr: !core/ndarray-1.1.0
data: [[1, 2, 3, 1234], [5, 6, 7, 8]]
mask: 1234
"""
Expand All @@ -415,7 +415,7 @@ def test_mask_arbitrary():

def test_mask_nan():
content = """
arr: !core/ndarray-1.0.0
arr: !core/ndarray-1.1.0
data: [[1, 2, 3, .NaN], [5, 6, 7, 8]]
mask: .NaN
"""
Expand Down Expand Up @@ -445,7 +445,7 @@ def test_string_table(tmp_path):


def test_inline_string():
content = "arr: !core/ndarray-1.0.0 ['a', 'b', 'c']"
content = "arr: !core/ndarray-1.1.0 ['a', 'b', 'c']"
buff = helpers.yaml_to_asdf(content)

with asdf.open(buff) as ff:
Expand All @@ -454,7 +454,7 @@ def test_inline_string():

def test_inline_structured():
content = """
arr: !core/ndarray-1.0.0
arr: !core/ndarray-1.1.0
datatype: [['ascii', 4], uint16, uint16, ['ascii', 4]]
data: [[M110, 110, 205, And],
[ M31, 31, 224, And],
Expand Down Expand Up @@ -611,10 +611,10 @@ def test_operations_on_ndarray_proxies(tmp_path):

def test_mask_datatype(tmp_path):
content = """
arr: !core/ndarray-1.0.0
arr: !core/ndarray-1.1.0
data: [1, 2, 3]
dtype: int32
mask: !core/ndarray-1.0.0
mask: !core/ndarray-1.1.0
data: [true, true, false]
"""
buff = helpers.yaml_to_asdf(content)
Expand All @@ -625,10 +625,10 @@ def test_mask_datatype(tmp_path):

def test_invalid_mask_datatype(tmp_path):
content = """
arr: !core/ndarray-1.0.0
arr: !core/ndarray-1.1.0
data: [1, 2, 3]
dtype: int32
mask: !core/ndarray-1.0.0
mask: !core/ndarray-1.1.0
data: ['a', 'b', 'c']
"""
buff = helpers.yaml_to_asdf(content)
Expand All @@ -646,7 +646,7 @@ def test_invalid_mask_datatype(tmp_path):
def test_ndim_validation(tmp_path):
content = """
obj: !<tag:nowhere.org:custom/ndim-1.0.0>
a: !core/ndarray-1.0.0
a: !core/ndarray-1.1.0
data: [1, 2, 3]
"""
buff = helpers.yaml_to_asdf(content)
Expand All @@ -661,7 +661,7 @@ def test_ndim_validation(tmp_path):

content = """
obj: !<tag:nowhere.org:custom/ndim-1.0.0>
a: !core/ndarray-1.0.0
a: !core/ndarray-1.1.0
data: [[1, 2, 3]]
"""
buff = helpers.yaml_to_asdf(content)
Expand All @@ -671,7 +671,7 @@ def test_ndim_validation(tmp_path):

content = """
obj: !<tag:nowhere.org:custom/ndim-1.0.0>
a: !core/ndarray-1.0.0
a: !core/ndarray-1.1.0
shape: [1, 3]
data: [[1, 2, 3]]
"""
Expand All @@ -682,7 +682,7 @@ def test_ndim_validation(tmp_path):

content = """
obj: !<tag:nowhere.org:custom/ndim-1.0.0>
b: !core/ndarray-1.0.0
b: !core/ndarray-1.1.0
data: [1, 2, 3]
"""
buff = helpers.yaml_to_asdf(content)
Expand All @@ -692,7 +692,7 @@ def test_ndim_validation(tmp_path):

content = """
obj: !<tag:nowhere.org:custom/ndim-1.0.0>
b: !core/ndarray-1.0.0
b: !core/ndarray-1.1.0
data: [[1, 2, 3]]
"""
buff = helpers.yaml_to_asdf(content)
Expand All @@ -702,7 +702,7 @@ def test_ndim_validation(tmp_path):

content = """
obj: !<tag:nowhere.org:custom/ndim-1.0.0>
b: !core/ndarray-1.0.0
b: !core/ndarray-1.1.0
data: [[[1, 2, 3]]]
"""
buff = helpers.yaml_to_asdf(content)
Expand All @@ -720,7 +720,7 @@ def test_ndim_validation(tmp_path):
def test_datatype_validation(tmp_path):
content = """
obj: !<tag:nowhere.org:custom/datatype-1.0.0>
a: !core/ndarray-1.0.0
a: !core/ndarray-1.1.0
data: [1, 2, 3]
datatype: float32
"""
Expand All @@ -731,7 +731,7 @@ def test_datatype_validation(tmp_path):

content = """
obj: !<tag:nowhere.org:custom/datatype-1.0.0>
a: !core/ndarray-1.0.0
a: !core/ndarray-1.1.0
data: [1, 2, 3]
datatype: float64
"""
Expand All @@ -747,7 +747,7 @@ def test_datatype_validation(tmp_path):

content = """
obj: !<tag:nowhere.org:custom/datatype-1.0.0>
a: !core/ndarray-1.0.0
a: !core/ndarray-1.1.0
data: [1, 2, 3]
datatype: int16
"""
Expand All @@ -758,7 +758,7 @@ def test_datatype_validation(tmp_path):

content = """
obj: !<tag:nowhere.org:custom/datatype-1.0.0>
b: !core/ndarray-1.0.0
b: !core/ndarray-1.1.0
data: [1, 2, 3]
datatype: int16
"""
Expand All @@ -774,7 +774,7 @@ def test_datatype_validation(tmp_path):

content = """
obj: !<tag:nowhere.org:custom/datatype-1.0.0>
a: !core/ndarray-1.0.0
a: !core/ndarray-1.1.0
data: [[1, 'a'], [2, 'b'], [3, 'c']]
datatype:
- name: a
Expand All @@ -797,7 +797,7 @@ def test_datatype_validation(tmp_path):
def test_structured_datatype_validation(tmp_path):
content = """
obj: !<tag:nowhere.org:custom/datatype-1.0.0>
c: !core/ndarray-1.0.0
c: !core/ndarray-1.1.0
data: [[1, 'a'], [2, 'b'], [3, 'c']]
datatype:
- name: a
Expand All @@ -812,7 +812,7 @@ def test_structured_datatype_validation(tmp_path):

content = """
obj: !<tag:nowhere.org:custom/datatype-1.0.0>
c: !core/ndarray-1.0.0
c: !core/ndarray-1.1.0
data: [[1, 'a'], [2, 'b'], [3, 'c']]
datatype:
- name: a
Expand All @@ -832,7 +832,7 @@ def test_structured_datatype_validation(tmp_path):

content = """
obj: !<tag:nowhere.org:custom/datatype-1.0.0>
c: !core/ndarray-1.0.0
c: !core/ndarray-1.1.0
data: [[1, 'a', 0], [2, 'b', 1], [3, 'c', 2]]
datatype:
- name: a
Expand All @@ -854,7 +854,7 @@ def test_structured_datatype_validation(tmp_path):

content = """
obj: !<tag:nowhere.org:custom/datatype-1.0.0>
c: !core/ndarray-1.0.0
c: !core/ndarray-1.1.0
data: [1, 2, 3]
"""
buff = helpers.yaml_to_asdf(content)
Expand All @@ -869,7 +869,7 @@ def test_structured_datatype_validation(tmp_path):

content = """
obj: !<tag:nowhere.org:custom/datatype-1.0.0>
d: !core/ndarray-1.0.0
d: !core/ndarray-1.1.0
data: [[1, 'a'], [2, 'b'], [3, 'c']]
datatype:
- name: a
Expand All @@ -889,7 +889,7 @@ def test_structured_datatype_validation(tmp_path):

content = """
obj: !<tag:nowhere.org:custom/datatype-1.0.0>
d: !core/ndarray-1.0.0
d: !core/ndarray-1.1.0
data: [[1, 'a'], [2, 'b'], [3, 'c']]
datatype:
- name: a
Expand All @@ -913,7 +913,7 @@ def test_string_inline():

def test_inline_shape_mismatch():
content = """
arr: !core/ndarray-1.0.0
arr: !core/ndarray-1.1.0
data: [1, 2, 3]
shape: [2]
"""
Expand Down
2 changes: 1 addition & 1 deletion asdf/_tests/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_extension_metadata(tmp_path):
with asdf.open(file_path) as af:
assert len(af.tree["history"]["extensions"]) == 1
metadata = af.tree["history"]["extensions"][0]
assert metadata.extension_uri == "asdf://asdf-format.org/core/extensions/core-1.5.0"
assert metadata.extension_uri == "asdf://asdf-format.org/core/extensions/core-1.6.0"
assert metadata.extension_class == "asdf.extension._manifest.ManifestExtension"
assert metadata.software["name"] == "asdf"
assert metadata.software["version"] == asdf.__version__
Expand Down
9 changes: 8 additions & 1 deletion asdf/_tests/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,14 @@ def test_recursive_info_object_support(capsys, tmp_path):
recursive_obj = RecursiveObjectWithInfoSupport()
recursive_obj.recursive = recursive_obj
tree = {"random": 3.14159, "rtest": recursive_obj}
af = asdf.AsdfFile(tree)
af = asdf.AsdfFile()
# we need to do this to avoid validation against the
# manifest (generated in manifest_extension) which is
# now supported with the default asdf standard 1.6.0
# I'm not sure why the manifest has this restriction
# and prior to switching to the default 1.6.0 was ignored
# which allowed this test to pass.
af._tree = tree
af.info(refresh_extension_manager=True)
captured = capsys.readouterr()
assert "recursive reference" in captured.out
Expand Down
22 changes: 12 additions & 10 deletions asdf/_tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TagReferenceExtension:
name:
type: string
things:
$ref: "http://stsci.edu/schemas/asdf/core/ndarray-1.0.0"
$ref: "http://stsci.edu/schemas/asdf/core/ndarray-1.1.0"
required: [name, things]
...
"""
Expand Down Expand Up @@ -126,7 +126,7 @@ def test_load_schema(tmp_path):
type: object
properties:
foobar:
$ref: "../core/ndarray-1.0.0"
$ref: "../core/ndarray-1.1.0"
required: [foobar]
...
Expand All @@ -149,7 +149,7 @@ def test_load_schema_with_full_tag(tmp_path):
type: object
properties:
foobar:
$ref: "tag:stsci.edu:asdf/core/ndarray-1.0.0"
$ref: "tag:stsci.edu:asdf/core/ndarray-1.1.0"
required: [foobar]
...
Expand All @@ -174,7 +174,7 @@ def test_load_schema_with_file_url(tmp_path):
type: object
properties:
foobar:
$ref: "http://stsci.edu/schemas/asdf/core/ndarray-1.0.0"
$ref: "http://stsci.edu/schemas/asdf/core/ndarray-1.1.0"
required: [foobar]
...
Expand Down Expand Up @@ -403,7 +403,7 @@ def test_property_order():
ff = asdf.AsdfFile(tree)
ff.write_to(buff)

ndarray_schema = schema.load_schema("http://stsci.edu/schemas/asdf/core/ndarray-1.0.0")
ndarray_schema = schema.load_schema("http://stsci.edu/schemas/asdf/core/ndarray-1.1.0")
property_order = ndarray_schema["anyOf"][1]["propertyOrder"]

last_index = 0
Expand Down Expand Up @@ -473,7 +473,7 @@ class CustomExtension:
# Make sure tags get validated inside of other tags that know
# nothing about them.
yaml = f"""
array: !core/ndarray-1.0.0
array: !core/ndarray-1.1.0
data: [0, 1, 2]
custom: !<{tag_uri}>
foo
Expand Down Expand Up @@ -536,7 +536,7 @@ def test_check_complex_default():

schema.check_schema(s)

s["properties"]["a"]["tag"] = "tag:stsci.edu/asdf/core/ndarray-1.0.0"
s["properties"]["a"]["tag"] = "tag:stsci.edu/asdf/core/ndarray-1.1.0"
with pytest.raises(ValidationError, match=r"mismatched tags, wanted .*, got .*"):
schema.check_schema(s)

Expand Down Expand Up @@ -623,6 +623,8 @@ class DefaultExtension:
extension_uri = "http://nowhere.org/extensions/custom/default-1.0.0"

with config_context() as cfg:
# later versions do not fill defaults
cfg.default_version = "1.5.0"
cfg.add_extension(DefaultExtension())
cfg.add_resource_mapping({schema_uri: tag_schema})
yaml = """
Expand All @@ -633,7 +635,7 @@ class DefaultExtension:
j:
l: 362
"""
buff = yaml_to_asdf(yaml)
buff = yaml_to_asdf(yaml, standard_version="1.5.0")
with asdf.open(buff) as ff:
assert "a" in ff.tree["custom"]
assert ff.tree["custom"]["a"] == 42
Expand Down Expand Up @@ -755,7 +757,7 @@ def test_tag_reference_validation():
custom: !<tag:nowhere.org:custom/tag_reference-1.0.0>
name:
"Something"
things: !core/ndarray-1.0.0
things: !core/ndarray-1.1.0
data: [1, 2, 3]
"""

Expand Down Expand Up @@ -812,7 +814,7 @@ class ForeignTagReferenceExtension:
a: !<tag:nowhere.org:custom/tag_reference-1.0.0>
name:
"Something"
things: !core/ndarray-1.0.0
things: !core/ndarray-1.1.0
data: [1, 2, 3]
"""

Expand Down
4 changes: 2 additions & 2 deletions asdf/_tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def test_undefined_tag():
!<tag:nowhere.org:custom/undefined_tag-1.0.0>
- 5
- {'message': 'there is no tag'}
- !core/ndarray-1.0.0
- !core/ndarray-1.1.0
[[1, 2, 3], [4, 5, 6]]
- !<tag:nowhere.org:custom/also_undefined-1.3.0>
- !core/ndarray-1.0.0 [[7],[8],[9],[10]]
- !core/ndarray-1.1.0 [[7],[8],[9],[10]]
- !core/complex-1.0.0 3.14j
"""
buff = yaml_to_asdf(yaml)
Expand Down
2 changes: 1 addition & 1 deletion asdf/_tests/test_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def test_explicit_tags():
#ASDF_STANDARD 1.5.0
%YAML 1.1
--- !<tag:stsci.edu:asdf/core/asdf-1.1.0>
foo: !<tag:stsci.edu:asdf/core/ndarray-1.0.0> [1, 2, 3]
foo: !<tag:stsci.edu:asdf/core/ndarray-1.1.0> [1, 2, 3]
..."""

# Check that fully qualified explicit tags work
Expand Down
Loading

0 comments on commit 772c0e8

Please sign in to comment.