summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/core/src/umath_loops.inc.src5
-rw-r--r--numpy/core/tests/test_regression.py2
2 files changed, 4 insertions, 3 deletions
diff --git a/numpy/core/src/umath_loops.inc.src b/numpy/core/src/umath_loops.inc.src
index 3332e9443..f10000e1b 100644
--- a/numpy/core/src/umath_loops.inc.src
+++ b/numpy/core/src/umath_loops.inc.src
@@ -1254,8 +1254,9 @@ C@TYPE@_sign(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
UNARY_LOOP {
const @type@ in1r = ((@type@ *)ip1)[0];
const @type@ in1i = ((@type@ *)ip1)[1];
- ((@type@ *)op1)[0] = CGT(in1r, in1i, 0, 0) ? 1 :
- (CLT(in1r, in1i, 0, 0) ? -1 : 0);
+ ((@type@ *)op1)[0] = CGT(in1r, in1i, 0, 0) ? 1 :
+ (CLT(in1r, in1i, 0, 0) ? -1 :
+ (CEQ(in1r, in1i, 0, 0) ? 0 : NAN));
((@type@ *)op1)[1] = 0;
}
}
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index 03425eba9..99ae43dfa 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -1176,7 +1176,7 @@ class TestRegression(TestCase):
"""Ticket 794."""
C = np.array([-np.inf, -2+1j, 0, 2-1j, np.inf, np.nan])
have = np.sign(C)
- want = np.array([-1+0j, -1+0j, 0+0j, 1+0j, 1+0j, 0+0j])
+ want = np.array([-1+0j, -1+0j, 0+0j, 1+0j, 1+0j, np.nan])
assert_equal(have, want)
def test_for_equal_names(self, level=rlevel):