8000 BUG: Fix MaskedArray.__setitem__ by eric-wieser · Pull Request #8648 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix MaskedArray.__setitem__ #8648

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 1 commit into from
Feb 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
BUG: Fix #8510, making MaskedArray.__setitem__ work
  • Loading branch information
eric-wieser committed Feb 20, 2017
commit 10bf55e6548e970481baf7b333aeab20743e5b3b
2 changes: 1 addition & 1 deletion numpy/ma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3264,7 +3264,7 @@ def __setitem__(self, indx, value):
return

# Get the _data part of the new value
dval = value
dval = getattr(value, '_data', value)
# Get the _mask part of the new value
mval = getattr(value, '_mask', nomask)
if nbfields and mval is nomask:
Expand Down
7 changes: 7 additions & 0 deletions numpy/ma/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4256,6 +4256,13 @@ def test_setitem(self):
a[0]['a'] = 2
assert_equal(a.mask, control)

def test_setitem_scalar(self):
# 8510
mask_0d = np.ma.masked_array(1, mask=True)
arr = np.ma.arange(3)
arr[0] = mask_0d
assert_array_equal(arr.mask, [True, False, False])

def test_element_len(self):
# check that len() works for mvoid (Github issue #576)
for rec in self.data['base']:
Expand Down
0