8000 1.10 deprecated removal by charris · Pull Request #5990 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
Prev Previous commit
Next Next commit
BUG: Fix wrong deprecation message for logical unary '-' operator.
  • Loading branch information
charris committed Jun 21, 2015
commit 81788b45e383d2f6494cf3daadbd7fb6bfc550b1
10 changes: 5 additions & 5 deletions numpy/core/src/umath/ufunc_type_resolution.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ PyUFunc_NegativeTypeResolver(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 negative (the unary `-` operator) is "
"deprecated, use the bitwise_xor (the `^` operator) "
"or the logical_xor function instead.") < 0) {
if (DEPRECATE("numpy boolean negative, the `-` operator, is "
"deprecated, use the `~` operator or the logical_not "
"function instead.") < 0) {
return -1;
}
}
Expand Down Expand Up @@ -801,8 +801,8 @@ 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 binary `-` operator) is "
"deprecated, use the bitwise_xor (the `^` operator) "
if (DEPRECATE("numpy boolean subtract, the `-` operator, is "
"deprecated, use the bitwise_xor, the `^` operator, "
"or the logical_xor function instead.") < 0) {
return -1;
}
Expand Down
30 changes: 22 additions & 8 deletions numpy/core/tests/test_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,32 @@ def test_basic(self):
assert_raises(IndexError, a.__getitem__, ((Ellipsis, ) * 3,))


class TestBooleanSubtractDeprecations(_DeprecationTestCase):
"""Test deprecation of boolean `-`. While + and * are well
defined, - is not and even a corrected form seems to have
class TestBooleanUnaryMinusDeprecation(_DeprecationTestCase):
"""Test deprecation of unary boolean `-`. While + and * are well
defined, unary - 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 .* \(the .* `-` operator\) is deprecated, " \
"use the bitwise"
message = r"numpy boolean negative, the `-` operator, .*"

def test_unary_minus_operator_deprecation(self):
array = np.array([True])
generic = np.bool_(True)

# Unary minus/negative ufunc:
self.assert_deprecated(operator.neg, args=(array,))
self.assert_deprecated(operator.neg, args=(generic,))


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])
Expand All @@ -363,9 +380,6 @@ def test_operator_deprecation(self):
self.assert_deprecated(operator.sub, args=(array, array))
self.assert_deprecated(operator.sub, args=(generic, generic))

# Unary minus/negative ufunc:
self.assert_deprecated(operator.neg, args=(array,))
self.assert_deprecated(operator.neg, args=(generic,))


class TestRankDeprecation(_DeprecationTestCase):
Expand Down
0