Skip to content

Commit

Permalink
Remove try statement. Add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmarmo committed Sep 7, 2022
1 parent 2d73e10 commit 4213779
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 1 addition & 4 deletions numpy/ma/core.py
Expand Up @@ -2357,10 +2357,7 @@ def masked_invalid(a, copy=True):
"""

try:
return masked_where(~(np.isfinite(getdata(a))), a, copy=copy)
except TypeError:
raise
return masked_where(~(np.isfinite(getdata(a))), a, copy=copy)

###############################################################################
# Printing options #
Expand Down
4 changes: 4 additions & 0 deletions numpy/ma/tests/test_core.py
Expand Up @@ -5317,6 +5317,10 @@ def test_masked_array_no_copy():
a = np.ma.array([1, 2, 3, 4], mask=[1, 0, 0, 0])
_ = np.ma.masked_where(a == 3, a, copy=False)
assert_array_equal(a.mask, [True, False, True, False])
# check masked array with masked_invalid is updated in place
a = np.ma.array([np.inf, 1, 2, 3, 4])
_ = np.ma.masked_invalid(a, copy=False)
assert_array_equal(a.mask, [True, False, False, False, False])

def test_append_masked_array():
a = np.ma.masked_equal([1,2,3], value=2)
Expand Down

0 comments on commit 4213779

Please sign in to comment.