ASDF (Advanced Scientific Data Format) is a next generation interchange format for scientific data
BSD 3-Clause "New" or "Revised" License
523
stars
57
forks
source link
`assert_tree_match` and `np.testing` ignores array masks #1806
Open
braingram opened 2 months ago
While reviewing https://github.com/asdf-format/asdf/pull/1803 a somewhat related issue was found. See https://github.com/asdf-format/asdf/pull/1803#issuecomment-2236535510 for the initial comment.
asdf._tests._helpers.assert_tree_match discards array masks during the comparison. This is caused by 2 related issues (both covered here) and this line: https://github.com/asdf-format/asdf/blob/33e7095df0c58705043de8f75497dfd64d04bbfb/asdf/_tests/_helpers.py#L55 The call to
__array__
drops the mask:returns
So the mask never makes it to
assert_array_equal
. Furthermore:Does not fail (as it appears
assert_array_equal
(andassert_equal
) ignore masks.As our test suite contains several masked arrays it seems worthwhile to:
assert_tree_match
to handle the masks (or remove that test function)np.testing
that might handle a masked array (I'm not sure if there's a drop-in replacement or some argument we can provide).