diff options
author | Julian Taylor <jtaylor.debian@googlemail.com> | 2017-05-12 17:28:47 +0200 |
---|---|---|
committer | Julian Taylor <jtaylor.debian@googlemail.com> | 2017-05-12 17:31:41 +0200 |
commit | fb67d49bf1e84c58833b8d4920397cee866e8daf (patch) | |
tree | 3462fdd1abf2f18fc13a5f953fe21098e9be1970 /numpy/core | |
parent | e571559ded7f041acdb5130f5f8722fea44ff4ad (diff) | |
download | numpy-fb67d49bf1e84c58833b8d4920397cee866e8daf.tar.gz |
BUG: do not elide complex abs()
complex abs() results in float so it cannot be elided.
Closes gh-9109
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/src/multiarray/number.c | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/number.c b/numpy/core/src/multiarray/number.c index 1f5523b90..d86cef5a1 100644 --- a/numpy/core/src/multiarray/number.c +++ b/numpy/core/src/multiarray/number.c @@ -565,7 +565,7 @@ array_negative(PyArrayObject *m1) static PyObject * array_absolute(PyArrayObject *m1) { - if (can_elide_temp_unary(m1)) { + if (can_elide_temp_unary(m1) && !PyArray_ISCOMPLEX(m1)) { return PyArray_GenericInplaceUnaryFunction(m1, n_ops.absolute); } return PyArray_GenericUnaryFunction(m1, n_ops.absolute); diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 835d03528..44dd17496 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -2850,6 +2850,9 @@ class TestBinop(object): d = f.astype(np.float64) assert_equal(((f + f) + d).dtype, np.dtype('f8')) + c = np.ones(100000, dtype=np.complex) + assert_equal(abs(c * 2.0).dtype, np.dtype('f8')) + def test_elide_broadcast(self): # test no elision on broadcast to higher dimension # only triggers elision code path in debug mode as triggering it in |