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

remove deprecated AsdfFile.open, asdf.open, write_to, update kwargs, #1592

Merged
merged 8 commits into from
Aug 7, 2023
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
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ The ASDF Standard is at v1.6.0
- Remove deprecated tests.helpers [#1597]
- Remove deprecated load_custom_schema [#1596]
- Remove deprecated TagDefinition.schema_uri [#1595]
- Removed deprecated AsdfFile.open and deprecated asdf.open
AsdfFile.write_to and AsdfFile.update kwargs [#1592]

2.15.1 (2023-08-07)
-------------------
Expand Down
43 changes: 0 additions & 43 deletions asdf/_tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,6 @@ def test_no_warning_nan_array(tmp_path):
assert_roundtrip_tree(tree, tmp_path)


def test_warning_deprecated_open(tmp_path):
tmpfile = str(tmp_path / "foo.asdf")

tree = {"foo": 42, "bar": "hello"}
with asdf.AsdfFile(tree) as af:
af.write_to(tmpfile)

with pytest.warns(AsdfDeprecationWarning), asdf.AsdfFile.open(tmpfile) as af:
assert_tree_match(tree, af.tree)


@pytest.mark.skipif(
not sys.platform.startswith("win") and getpass.getuser() == "root",
reason="Cannot make file read-only if user is root",
Expand Down Expand Up @@ -355,38 +344,6 @@ def test_extension_version_check(installed, extension, warns):
af._check_extensions(tree)


@pytest.mark.filterwarnings(AsdfDeprecationWarning)
def test_auto_inline(tmp_path):
outfile = str(tmp_path / "test.asdf")
tree = {"small_array": np.arange(6), "large_array": np.arange(100)}

# Use the same object for each write in order to make sure that there
# aren't unanticipated side effects
with asdf.AsdfFile(tree) as af:
# By default blocks are written internal.
af.write_to(outfile)
assert len(list(af._blocks.inline_blocks)) == 0
assert len(list(af._blocks.internal_blocks)) == 2

af.write_to(outfile, auto_inline=10)
assert len(list(af._blocks.inline_blocks)) == 1
assert len(list(af._blocks.internal_blocks)) == 1

# The previous write modified the small array block's storage
# to inline, and a subsequent write should maintain that setting.
af.write_to(outfile)
assert len(list(af._blocks.inline_blocks)) == 1
assert len(list(af._blocks.internal_blocks)) == 1

af.write_to(outfile, auto_inline=7)
assert len(list(af._blocks.inline_blocks)) == 1
assert len(list(af._blocks.internal_blocks)) == 1

af.write_to(outfile, auto_inline=5)
assert len(list(af._blocks.inline_blocks)) == 0
assert len(list(af._blocks.internal_blocks)) == 2


@pytest.mark.parametrize(
("array_inline_threshold", "inline_blocks", "internal_blocks"),
[
Expand Down
57 changes: 21 additions & 36 deletions asdf/_tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,42 +487,6 @@ def types(self):
assert "k" not in ff.tree["custom"]["j"]
assert ff.tree["custom"]["j"]["l"] == 362

buff.seek(0)
with pytest.warns(AsdfDeprecationWarning, match=r"do_not_fill_defaults"), asdf.open(
buff,
extensions=[DefaultTypeExtension()],
do_not_fill_defaults=True,
) as ff:
assert "a" not in ff.tree["custom"]
assert "c" not in ff.tree["custom"]["b"]
assert "e" not in ff.tree["custom"]["d"]
assert "f" not in ff.tree["custom"]["d"]
assert "h" not in ff.tree["custom"]["g"]
assert "i" not in ff.tree["custom"]["g"]
assert "k" not in ff.tree["custom"]["j"]
assert ff.tree["custom"]["j"]["l"] == 362
ff.fill_defaults()
assert "a" in ff.tree["custom"]
assert ff.tree["custom"]["a"] == 42
assert "c" in ff.tree["custom"]["b"]
assert ff.tree["custom"]["b"]["c"] == 82
assert ff.tree["custom"]["b"]["c"] == 82
assert ff.tree["custom"]["d"]["e"] == 122
assert ff.tree["custom"]["d"]["f"] == 162
assert "h" not in ff.tree["custom"]["g"]
assert "i" not in ff.tree["custom"]["g"]
assert "k" not in ff.tree["custom"]["j"]
assert ff.tree["custom"]["j"]["l"] == 362
ff.remove_defaults()
assert "a" not in ff.tree["custom"]
assert "c" not in ff.tree["custom"]["b"]
assert "e" not in ff.tree["custom"]["d"]
assert "f" not in ff.tree["custom"]["d"]
assert "h" not in ff.tree["custom"]["g"]
assert "i" not in ff.tree["custom"]["g"]
assert "k" not in ff.tree["custom"]["j"]
assert ff.tree["custom"]["j"]["l"] == 362

buff.seek(0)
with config_context() as config:
config.legacy_fill_schema_defaults = False
Expand All @@ -535,6 +499,27 @@ def types(self):
assert "i" not in ff.tree["custom"]["g"]
assert "k" not in ff.tree["custom"]["j"]
assert ff.tree["custom"]["j"]["l"] == 362
ff.fill_defaults()
assert "a" in ff.tree["custom"]
assert ff.tree["custom"]["a"] == 42
assert "c" in ff.tree["custom"]["b"]
assert ff.tree["custom"]["b"]["c"] == 82
assert ff.tree["custom"]["b"]["c"] == 82
assert ff.tree["custom"]["d"]["e"] == 122
assert ff.tree["custom"]["d"]["f"] == 162
assert "h" not in ff.tree["custom"]["g"]
assert "i" not in ff.tree["custom"]["g"]
assert "k" not in ff.tree["custom"]["j"]
assert ff.tree["custom"]["j"]["l"] == 362
ff.remove_defaults()
assert "a" not in ff.tree["custom"]
assert "c" not in ff.tree["custom"]["b"]
assert "e" not in ff.tree["custom"]["d"]
assert "f" not in ff.tree["custom"]["d"]
assert "h" not in ff.tree["custom"]["g"]
assert "i" not in ff.tree["custom"]["g"]
assert "k" not in ff.tree["custom"]["j"]
assert ff.tree["custom"]["j"]["l"] == 362


def test_one_of():
Expand Down
Loading
Loading