diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/umath/ufunc_type_resolution.c | 11 | ||||
-rw-r--r-- | numpy/core/tests/test_deprecations.py | 18 | ||||
-rw-r--r-- | numpy/core/tests/test_scalarmath.py | 16 | ||||
-rw-r--r-- | numpy/core/tests/test_umath.py | 1 |
4 files changed, 21 insertions, 25 deletions
diff --git a/numpy/core/src/umath/ufunc_type_resolution.c b/numpy/core/src/umath/ufunc_type_resolution.c index 247526a54..154dbfb2f 100644 --- a/numpy/core/src/umath/ufunc_type_resolution.c +++ b/numpy/core/src/umath/ufunc_type_resolution.c @@ -796,12 +796,11 @@ PyUFunc_SubtractionTypeResolver(PyUFuncObject *ufunc, /* The type resolver would have upcast already */ if (out_dtypes[0]->type_num == NPY_BOOL) { - /* 2013-12-05, 1.9 */ - if (DEPRECATE("numpy boolean subtract, the `-` operator, is " - "deprecated, use the bitwise_xor, the `^` operator, " - "or the logical_xor function instead.") < 0) { - return -1; - } + PyErr_Format(PyExc_TypeError, + "numpy boolean subtract, the `-` operator, is deprecated, " + "use the bitwise_xor, the `^` operator, or the logical_xor " + "function instead."); + return -1; } return ret; } diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py index 49fe49be9..f8de4f014 100644 --- a/numpy/core/tests/test_deprecations.py +++ b/numpy/core/tests/test_deprecations.py @@ -226,24 +226,6 @@ class _DeprecationTestCase(object): exceptions=tuple(), args=args, kwargs=kwargs) -class TestBooleanBinaryMinusDeprecation(_DeprecationTestCase): - """Test deprecation of binary boolean `-`. While + and * are well - defined, binary - is not and even a corrected form seems to have - no real uses. - - The deprecation process was started in NumPy 1.9. - """ - message = r"numpy boolean subtract, the `-` operator, .*" - - def test_operator_deprecation(self): - array = np.array([True]) - generic = np.bool_(True) - - # Minus operator/subtract ufunc: - self.assert_deprecated(operator.sub, args=(array, array)) - self.assert_deprecated(operator.sub, args=(generic, generic)) - - class TestRankDeprecation(_DeprecationTestCase): """Test that np.rank is deprecated. The function should simply be removed. The VisibleDeprecationWarning may become unnecessary. diff --git a/numpy/core/tests/test_scalarmath.py b/numpy/core/tests/test_scalarmath.py index 33713b986..e43a0b2e0 100644 --- a/numpy/core/tests/test_scalarmath.py +++ b/numpy/core/tests/test_scalarmath.py @@ -555,12 +555,26 @@ class TestNegative(TestCase): def test_result(self): types = np.typecodes['AllInteger'] + np.typecodes['AllFloat'] with suppress_warnings() as sup: - sup.filter(RuntimeWarning) + sup.filter(RuntimeWarning) for dt in types: a = np.ones((), dtype=dt)[()] assert_equal(operator.neg(a) + a, 0) +class TestSubtract(TestCase): + def test_exceptions(self): + a = np.ones((), dtype=np.bool_)[()] + assert_raises(TypeError, operator.sub, a, a) + + def test_result(self): + types = np.typecodes['AllInteger'] + np.typecodes['AllFloat'] + with suppress_warnings() as sup: + sup.filter(RuntimeWarning) + for dt in types: + a = np.ones((), dtype=dt)[()] + assert_equal(operator.sub(a, a), 0) + + class TestAbs(TestCase): def _test_abs_func(self, absfunc): diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py index 0275d10c6..c9dbef080 100644 --- a/numpy/core/tests/test_umath.py +++ b/numpy/core/tests/test_umath.py @@ -1005,6 +1005,7 @@ class TestBool(TestCase): def test_exceptions(self): a = np.ones(1, dtype=np.bool_) assert_raises(TypeError, np.negative, a) + assert_raises(TypeError, np.subtract, a, a) def test_truth_table_logical(self): # 2, 3 and 4 serves as true values |