diff options
author | David Cournapeau <cournape@gmail.com> | 2008-08-23 23:21:40 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2008-08-23 23:21:40 +0000 |
commit | 3d22be4768f0eecbcfda878febe88b630f93a8eb (patch) | |
tree | 76479f29f3daf352fc01325260eaf4f5b1adb101 | |
parent | e2b433e669cff070227ebb8d244e23c68a23e65c (diff) | |
download | numpy-3d22be4768f0eecbcfda878febe88b630f93a8eb.tar.gz |
Backport fix to #698.
-rw-r--r-- | numpy/core/memmap.py | 1 | ||||
-rw-r--r-- | numpy/core/src/scalarmathmodule.c.src | 42 |
2 files changed, 42 insertions, 1 deletions
diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py index c7705d263..175e5688b 100644 --- a/numpy/core/memmap.py +++ b/numpy/core/memmap.py @@ -195,6 +195,7 @@ class memmap(ndarray): self = ndarray.__new__(subtype, shape, dtype=descr, buffer=mm, offset=offset, order=order) self._mmap = mm +# Should get rid of these... Are they used? self._offset = offset self._mode = mode self._size = size diff --git a/numpy/core/src/scalarmathmodule.c.src b/numpy/core/src/scalarmathmodule.c.src index b6089d0cb..1daf83f68 100644 --- a/numpy/core/src/scalarmathmodule.c.src +++ b/numpy/core/src/scalarmathmodule.c.src @@ -524,6 +524,13 @@ _@name@_convert_to_ctype(PyObject *a, @name@ *arg1) return -2; } +/**end repeat**/ + + +/**begin repeat + #name=byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong,float,double,cfloat,cdouble# +**/ + static int _@name@_convert2_to_ctypes(PyObject *a, @name@ *arg1, PyObject *b, @name@ *arg2) @@ -539,6 +546,27 @@ _@name@_convert2_to_ctypes(PyObject *a, @name@ *arg1, /**end repeat**/ /**begin repeat + #name=longdouble, clongdouble# +**/ + +static int +_@name@_convert2_to_ctypes(PyObject *a, @name@ *arg1, + PyObject *b, @name@ *arg2) +{ + int ret; + ret = _@name@_convert_to_ctype(a, arg1); + if (ret < 0) return ret; + ret = _@name@_convert_to_ctype(b, arg2); + if (ret == -2) ret = -3; + if (ret < 0) return ret; + return 0; +} + +/**end repeat**/ + + + +/**begin repeat #name=(byte,ubyte,short,ushort,int,uint,long,ulong,longlong,ulonglong)*13, (float, double, longdouble, cfloat, cdouble, clongdouble)*6, (float, double, longdouble)*2# #Name=(Byte, UByte, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong)*13, (Float, Double, LongDouble, CFloat, CDouble, CLongDouble)*6, (Float, Double, LongDouble)*2# #oper=add*10, subtract*10, multiply*10, divide*10, remainder*10, divmod*10, floor_divide*10, lshift*10, rshift*10, and*10, or*10, xor*10, true_divide*10, add*6, subtract*6, multiply*6, divide*6, floor_divide*6, true_divide*6, divmod*3, remainder*3# @@ -569,10 +597,14 @@ static PyObject * break; case -1: /* one of them can't be cast safely must be mixed-types*/ - return PyArray_Type.tp_as_number->nb_@oper@(a,b); + return PyArray_Type.tp_as_number->nb_@oper@(a,b); case -2: /* use default handling */ if (PyErr_Occurred()) return NULL; return PyGenericArrType_Type.tp_as_number->nb_@oper@(a,b); + case -3: /* special case for longdouble and clongdouble + because they have a recursive getitem in their dtype */ + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; } #if @fperr@ @@ -658,6 +690,10 @@ static PyObject * case -2: /* use default handling */ if (PyErr_Occurred()) return NULL; return PyGenericArrType_Type.tp_as_number->nb_power(a,b,NULL); + case -3: /* special case for longdouble and clongdouble + because they have a recursive getitem in their dtype */ + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; } PyUFunc_clearfperr(); @@ -887,6 +923,10 @@ static PyObject* case -2: /* use ufunc */ if (PyErr_Occurred()) return NULL; return PyGenericArrType_Type.tp_richcompare(self, other, cmp_op); + case -3: /* special case for longdouble and clongdouble + because they have a recursive getitem in their dtype */ + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; } /* here we do the actual calculation with arg1 and arg2 */ |