Skip to content

Commit

Permalink
move test to test_ndarray
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett committed Jul 18, 2024
1 parent 4f56b44 commit 2eb5c40
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 35 deletions.
25 changes: 16 additions & 9 deletions asdf/_tests/tags/core/tests/test_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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
Expand Down Expand Up @@ -378,17 +379,23 @@ def test_inline_bare():
assert_array_equal(ff.tree["arr"], [[1, 2, 3, 4], [5, 6, 7, 8]])


def test_mask_roundtrip(tmp_path):
x = np.arange(0, 10, dtype=float)
m = ma.array(x, mask=x > 5)
tree = {"masked_array": m, "unmasked_array": x}
@pytest.mark.parametrize(
"mask",
[
[[False, False, True], [False, True, False], [False, False, False]],
True,
False,
],
)
def test_mask_roundtrip(mask, tmp_path):
array = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 0]])
tree = {
"unmasked": array,
"masked": np.ma.array(array, mask=mask),
}

with roundtrip(tree) as af:
tree = af.tree

m = tree["masked_array"]

assert np.all(m.mask[6:])
assert_tree_match(tree, af.tree)
assert len(af._blocks.blocks) == 2


Expand Down
26 changes: 0 additions & 26 deletions asdf/_tests/test_masked.py

This file was deleted.

0 comments on commit 2eb5c40

Please sign in to comment.