diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-09-23 10:12:16 -0700 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-09-23 11:16:19 -0700 |
commit | 2c79962d20d0ebc37a65e4f7325788f5a55bee13 (patch) | |
tree | 01d479a9b5c3f1f2f06919eafa64be2c22adc945 | |
parent | 89ba7bf507ea41e242cb4cb349b899b1e39cb449 (diff) | |
download | numpy-2c79962d20d0ebc37a65e4f7325788f5a55bee13.tar.gz |
BUG: Fix silent loss of clongdouble precision
This was not caught in gh-8903
-rw-r--r-- | numpy/core/src/multiarray/arraytypes.c.src | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src index 43dd101c5..ccf3a3a7d 100644 --- a/numpy/core/src/multiarray/arraytypes.c.src +++ b/numpy/core/src/multiarray/arraytypes.c.src @@ -289,37 +289,26 @@ static int { PyArrayObject *ap = vap; Py_complex oop; - PyObject *op2; @type@ temp; int rsize; + if (PyArray_IsZeroDim(op)) { + return convert_to_scalar_and_retry(op, ov, vap, @NAME@_setitem); + } + if (PyArray_IsScalar(op, @kind@)){ temp = ((Py@kind@ScalarObject *)op)->obval; } else { - if (PyArray_IsZeroDim(op)) { - /* - * TODO: Elsewhere in this file we use PyArray_ToScalar. Is this - * better or worse? Possibly an optimization. - */ - op2 = PyArray_DESCR((PyArrayObject *)op)->f->getitem( - PyArray_BYTES((PyArrayObject *)op), - (PyArrayObject *)op); - } - else { - op2 = op; - Py_INCREF(op); - } - if (op2 == Py_None) { + if (op == Py_None) { oop.real = NPY_NAN; oop.imag = NPY_NAN; } else { - oop = PyComplex_AsCComplex (op2); - } - Py_DECREF(op2); - if (PyErr_Occurred()) { - return -1; + oop = PyComplex_AsCComplex (op); + if (PyErr_Occurred()) { + return -1; + } } temp.real = (@ftype@) oop.real; temp.imag = (@ftype@) oop.imag; |