From 4f56b4417a5938d568dc55b5d1355ae0fb304241 Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Wed, 17 Jul 2024 14:48:58 -0400 Subject: [PATCH] add unit test for masked array roundtripping --- asdf/_tests/test_masked.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 asdf/_tests/test_masked.py diff --git a/asdf/_tests/test_masked.py b/asdf/_tests/test_masked.py new file mode 100644 index 000000000..b126cf5ae --- /dev/null +++ b/asdf/_tests/test_masked.py @@ -0,0 +1,26 @@ +import numpy.ma +import pytest + +import asdf +from asdf._tests._helpers import assert_tree_match + + +@pytest.mark.parametrize( + "mask", + [ + [[False, False, True], [False, True, False], [False, False, False]], + True, + False, + ], +) +def test_masked(mask, tmp_path): + tree = { + "a": 1, + "b": numpy.ma.array([[1, 0, 0], [0, 1, 0], [0, 0, 0]], mask=mask), + } + af = asdf.AsdfFile(tree) + fn = tmp_path / "masked.asdf" + af.write_to(fn) + + with asdf.open(fn) as af: + assert_tree_match(tree, af.tree)