8000 ENH: Add ma.convolve and ma.correlate for #6458 by eric-wieser · Pull Request #7922 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Add ma.convolve and ma.correlate for #6458 #7922

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 4 commits into from
Oct 20, 2016
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
BUG: Fix (and test) np.ma.convolve for raw lists
  • Loading branch information
eric-wieser committed Oct 19, 2016
commit 4c2ad8a4a23524f422f476c1596c973c4308e5da
4 changes: 2 additions & 2 deletions numpy/ma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7373,8 +7373,8 @@ def _convolve_or_correlate(f, a, v, mode, propagate_mask):
if propagate_mask:
# results which are contributed to by either item in any pair being invalid
mask = (
f(getmaskarray(a), np.ones(v.shape, dtype=np.bool), mode=mode)
| f(np.ones(a.shape, dtype=np.bool), getmaskarray(v), mode=mode)
f(getmaskarray(a), np.ones(np.shape(v), dtype=np.bool), mode=mode)
| f(np.ones(np.shape(a), dtype=np.bool), getmaskarray(v), mode=mode)
)
data = f(getdata(a), getdata(v), mode=mode)
else:
Expand Down
10 changes: 10 additions & 0 deletions numpy/ma/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4095,6 +4095,16 @@ def test_convolve(self):
test = np.ma.convolve(a, b, propagate_mask=False)
assert_equal(test, masked_equal([0, 1, 1, 3, 7, 4], -1))

test = np.ma.convolve([1, 1], [1, 1, 1])
assert_equal(test, masked_equal([1, 2, 2, 1], -1))

a = [1, 1]
b = masked_equal([1, -1, -1, 1], -1)
test = np.ma.convolve(a, b, propagate_mask=False)
assert_equal(test, masked_equal([1, 1, -1, 1, 1], -1))
test = np.ma.convolve(a, b, propagate_mask=True)
assert_equal(test, masked_equal([-1, -1, -1, -1, -1], -1))


class TestMaskedFields(TestCase):

Expand Down
0