diff options
| author | Matti Picus <matti.picus@gmail.com> | 2022-07-09 21:22:16 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-09 21:22:16 +0300 |
| commit | 072ae770150a70e1821f71302b43cee4bba7055c (patch) | |
| tree | 55087e95fb28e9fe7b37b523ff394e99e67504f1 /numpy/ma/tests | |
| parent | 0e5770d7458f30ee745809a21ed47ae7d999be02 (diff) | |
| download | numpy-072ae770150a70e1821f71302b43cee4bba7055c.tar.gz | |
Revert "ENH: Adding __array_ufunc__ capability to MaskedArrays"
Diffstat (limited to 'numpy/ma/tests')
| -rw-r--r-- | numpy/ma/tests/test_core.py | 4 | ||||
| -rw-r--r-- | numpy/ma/tests/test_subclassing.py | 59 |
2 files changed, 2 insertions, 61 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 5b779edcb..b056d5169 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -3208,7 +3208,7 @@ class TestMaskedArrayMethods: assert_equal(b.fill_value, 9999) assert_equal(b, a[condition]) - condition = (a.data < 4.) + condition = (a < 4.) b = a.compress(condition) assert_equal(b._data, [1., 2., 3.]) assert_equal(b._mask, [0, 0, 1]) @@ -5367,7 +5367,7 @@ def test_ufunc_with_out_varied(): a = array([ 1, 2, 3], mask=[1, 0, 0]) b = array([10, 20, 30], mask=[1, 0, 0]) out = array([ 0, 0, 0], mask=[0, 0, 1]) - expected = array([1, 22, 33], mask=[1, 0, 0]) + expected = array([11, 22, 33], mask=[1, 0, 0]) out_pos = out.copy() res_pos = np.add(a, b, out_pos) diff --git a/numpy/ma/tests/test_subclassing.py b/numpy/ma/tests/test_subclassing.py index 91b4241b5..3491cef7f 100644 --- a/numpy/ma/tests/test_subclassing.py +++ b/numpy/ma/tests/test_subclassing.py @@ -7,7 +7,6 @@ """ import numpy as np -from numpy.lib.mixins import NDArrayOperatorsMixin from numpy.testing import assert_, assert_raises from numpy.ma.testutils import assert_equal from numpy.ma.core import ( @@ -148,33 +147,6 @@ class ComplicatedSubArray(SubArray): return obj -class WrappedArray(NDArrayOperatorsMixin): - """ - Wrapping a MaskedArray rather than subclassing to test that - ufunc deferrals are commutative. - See: https://github.com/numpy/numpy/issues/15200) - """ - __array_priority__ = 20 - - def __init__(self, array, **attrs): - self._array = array - self.attrs = attrs - - def __repr__(self): - return f"{self.__class__.__name__}(\n{self._array}\n{self.attrs}\n)" - - def __array__(self): - return np.asarray(self._array) - - def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): - if method == '__call__': - inputs = [arg._array if isinstance(arg, self.__class__) else arg - for arg in inputs] - return self.__class__(ufunc(*inputs, **kwargs), **self.attrs) - else: - return NotImplemented - - class TestSubclassing: # Test suite for masked subclasses of ndarray. @@ -412,34 +384,3 @@ def test_array_no_inheritance(): # Test that the mask is False and not shared when keep_mask=False assert_(not new_array.mask) assert_(not new_array.sharedmask) - - -class TestClassWrapping: - # Test suite for classes that wrap MaskedArrays - - def setup(self): - m = np.ma.masked_array([1, 3, 5], mask=[False, True, False]) - wm = WrappedArray(m) - self.data = (m, wm) - - def test_masked_unary_operations(self): - # Tests masked_unary_operation - (m, wm) = self.data - with np.errstate(divide='ignore'): - assert_(isinstance(np.log(wm), WrappedArray)) - - def test_masked_binary_operations(self): - # Tests masked_binary_operation - (m, wm) = self.data - # Result should be a WrappedArray - assert_(isinstance(np.add(wm, wm), WrappedArray)) - assert_(isinstance(np.add(m, wm), WrappedArray)) - assert_(isinstance(np.add(wm, m), WrappedArray)) - # add and '+' should call the same ufunc - assert_equal(np.add(m, wm), m + wm) - assert_(isinstance(np.hypot(m, wm), WrappedArray)) - assert_(isinstance(np.hypot(wm, m), WrappedArray)) - # Test domained binary operations - assert_(isinstance(np.divide(wm, m), WrappedArray)) - assert_(isinstance(np.divide(m, wm), WrappedArray)) - assert_equal(np.divide(wm, m) * m, np.divide(m, m) * wm) |
