From 4e68aba658a6e54d09150f093cdb6f9d4883b081 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Sun, 28 Jul 2019 14:55:13 -0700 Subject: [PATCH] BUG: Remove the broken clip wrapper ndarray.clip is already just a wrapper for the ufunc, so there is no need to do type-specific wrapping here any more Fixes gh-14140 --- numpy/ma/core.py | 1 - numpy/ma/tests/test_core.py | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 93eb4d87af2b..d61d06d386d7 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -5870,7 +5870,6 @@ def take(self, indices, axis=None, out=None, mode='raise'): return out[()] # Array methods - clip = _arraymethod('clip', onmask=False) copy = _arraymethod('copy') diagonal = _arraymethod('diagonal') flatten = _arraymethod('flatten') diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index fb3f1a810807..cf11b6096318 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -3035,6 +3035,13 @@ def test_clip(self): assert_equal(clipped._data, x.clip(2, 8)) assert_equal(clipped._data, mx._data.clip(2, 8)) + def test_clip_out(self): + # gh-14140 + a = np.arange(10) + m = np.ma.MaskedArray(a, mask=[0, 1] * 5) + m.clip(0, 5, out=m) + assert_equal(m.mask, [0, 1] * 5) + def test_compress(self): # test compress a = masked_array([1., 2., 3., 4., 5.], fill_value=9999)