From 00c9703b34d254814ed279513645af316161024a Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Thu, 18 Jul 2024 09:48:59 -0400 Subject: [PATCH] numpy assertion helpers ignore masks --- asdf/_tests/tags/core/tests/test_ndarray.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/asdf/_tests/tags/core/tests/test_ndarray.py b/asdf/_tests/tags/core/tests/test_ndarray.py index 4ab62299a..f6743b577 100644 --- a/asdf/_tests/tags/core/tests/test_ndarray.py +++ b/asdf/_tests/tags/core/tests/test_ndarray.py @@ -11,7 +11,6 @@ from numpy.testing import assert_array_equal import asdf -from asdf._tests._helpers import assert_tree_match from asdf.exceptions import ValidationError from asdf.extension import Converter, Extension, TagDefinition from asdf.tags.core import ndarray @@ -395,7 +394,10 @@ def test_mask_roundtrip(mask, tmp_path): } with roundtrip(tree) as af: - assert_tree_match(tree, af.tree) + # assert_array_equal ignores the mask, so use equality here + assert tree["masked"] == af["masked"] + # ensure tree validity + assert af["unmasked"] == af["masked"].data assert len(af._blocks.blocks) == 2 @@ -527,7 +529,8 @@ def test_inline_masked_array(tmp_path): with asdf.open(testfile) as f2: assert len(list(f2._blocks.blocks)) == 0 - assert_array_equal(f.tree["test"], f2.tree["test"]) + # assert_array_equal ignores the mask, so use equality here + assert f.tree["test"] == f2.tree["test"] with open(testfile, "rb") as fd: assert b"null" in fd.read()