Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

BUG: fix np.ma.masked_where(copy=False) when input has no mask #18967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
BUG: fix linter
  • Loading branch information
constanzafierro committed May 9, 2021
commit 43ed940c6ef74a3f8dd26b731de2b96c9183767a
4 changes: 2 additions & 2 deletions 4 numpy/ma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1936,8 +1936,8 @@ def masked_where(condition, a, copy=True):
result = a.view(cls)
# Assign to *.mask so that structured masks are handled correctly.
result.mask = _shrink_mask(cond)
# There is no view of a boolean so when 'a' is a MaskedArray with nomask the
# update to the result's mask has no effect.
# There is no view of a boolean so when 'a' is a MaskedArray with nomask
# the update to the result's mask has no effect.
if not copy and hasattr(a, '_mask') and getmask(a) is nomask:
a._mask = result._mask.view()
return result
Expand Down
8 changes: 4 additions & 4 deletions 8 numpy/ma/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5178,12 +5178,12 @@ def test_masked_array():
def test_masked_array_no_copy():
# check nomask array is updated in place
a = np.ma.array([1, 2, 3, 4])
_ = np.ma.masked_where(a==3, a, copy=False)
assert_array_equal(a.mask, [False, False, True, False])
_ = np.ma.masked_where(a == 3, a, copy=False)
assert_array_equal(a.mask, [False, False, True, False])
# check masked array is updated in place
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])
_ = np.ma.masked_where(a == 3, a, copy=False)
assert_array_equal(a.mask, [True, False, True, False])

def test_append_masked_array():
a = np.ma.masked_equal([1,2,3], value=2)
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.